473,378 Members | 1,280 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Get the hostname

Hi
How can i get the hostname of my Linux PC?
I tried os.system('hostname') but i cant save the hostname in a variable
like hostname = os.system('hostname')

thanks
Lukas Schnieper
Jul 18 '05 #1
2 38960
admirm
2
Hi
How can i get the hostname of my Linux PC?
I tried os.system('hostname') but i cant save the hostname in a variable
like hostname = os.system('hostname')

thanks
Lukas Schnieper
Try this code:

import socket
host = socket.gethostname()
print host

Lp,
admirm
admir.mustafic@xxxxxx.xx
Jul 27 '06 #2
admirm
2
Even better code :)
socket.gethostbyaddr(socket.gethostname())
Jul 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Claus van de Vlierd | last post by:
Hello , a) in the following script (under RedHat AS3 with PHP 4.3.2 ) I make a "DB::connect" to an existing "mysql" database named "docu_files_of_cvdv" . The strange thing is : it works --...
2
by: Tim Veldhuizen | last post by:
Hi all! I'm attempting at writing a networked program. It is going to be a threaded irc server in c++ using almost nothing but oop code. And it needs to know the full hostname of the users that...
2
by: James M. | last post by:
I have 2x Front-end Web servers (Win2003 Ent IIS6.0), setup with NLB (single Affinity, also using SQLServer session state) that are hosting a few .NET ASP web applications under the Default Website...
3
by: Microlong® | last post by:
Currently, I want to get the IP address from giving hostname in the Active Server Page. I know the hostname, I want to get the IP address via hostname in an ASP page. -- Developer QA Dashboard...
3
by: HiChetu | last post by:
I have a host which has two NIC cards; one configured for LAN connections, and another for external connections. Say the ip address are 1) x.x.x.x - for LAN 2) y.y.y.y - for external ...
0
by: James M via .NET 247 | last post by:
(I have 2x Front-end Web servers (Win2003 Ent IIS6.0), setup withNLB (single Affinity, also using SQLServer session state) thatare hosting a few .NET ASP web applications under the DefaultWebsite in...
6
by: Eric Rechter | last post by:
Hi, I only want to display the provider name from a hostname, so I need to divide the string to take only de characters from after the before last dot. For example: ...
2
by: slinkp | last post by:
Can anybody explain this one? pw@kermit ~ $ python Python 2.4.3 (#1, Jul 27 2006, 13:07:44) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most...
3
by: Mark Delaney | last post by:
When using the MS SQL 2005 JDBC driver, I now need to have the DNS name resolution to the client correctly set up. If not I get the following error: SQLState: 08S01 SQLError: 0 Message:...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.