473,406 Members | 2,705 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,406 software developers and data experts.

How to get computer name

How do I get the computer name in python?

I've been looking over the internet, and couldn't find anything.

Thanks!

Bud

Apr 29 '06 #1
3 27399
"pitarda" <pi*****@gmail.com> writes:
How do I get the computer name in python?


You can use the os module to get it from your environment.
import os
os.getenv('HOSTNAME') 'calvin.watterson'

Depending on your operating system, the environment variable you need
might have a different name. For example, I think in Windows you
might try
os.getenv('COMPUTERNAME')
You can see all of the environment variables currently available with
os.environ


I hope this helps,

Tim
Apr 29 '06 #2
Thanks! :)

Though,... I think once I saw something like: getComputerByName but
can't find it anymore,...

:)

Apr 29 '06 #3
On 29 Apr 2006 10:04:39 -0700, pitarda wrote:
Thanks! :)

Though,... I think once I saw something like: getComputerByName but
can't find it anymore,...

:)

import socket
print socket.gethostname() blade print socket.gethostbyname('blade') # will print IP address

--
Richard
Apr 29 '06 #4

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

Similar topics

5
by: Maverick | last post by:
I'm trying to get the " Computer Name " of a client accessing my web site, is there a way to do this ? not ip... tia
3
by: RR | last post by:
I'm developing a web app and, for the user's convenience, I'd like to display their local computer name (i.e. the name of the computer the browser is running on). I've looked very hard to find a...
4
by: Dr. StrangeDub | last post by:
Leaving network identification/DNS out of the picture, how does one change the name of a computer in a local Workgroup (in C#)? I implemented the SetComputerName() API call and that only seems to...
1
by: Uzi Baruch | last post by:
Hi! i want to know if i have an ip address of a computer and its DNS server name, if their is an windows API that can resolve the computer name of the given ip address. or vice verca -...
5
by: z. f. | last post by:
i need to get the computer name from an aspx page. i use System.Windows.Forms.SystemInformation.ComputerName() and it's working fine, but in second thought, it might not be recomended to use the...
1
by: greg chu | last post by:
Hi, I tried to use Private Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long SetComputerName(newname) newname is the name I...
5
by: ThunderMusic | last post by:
Hi, I want to find the computer name and the company name from the network indentification informations. For the computer name, I found System.Net.Dns.GetHostName(), but I fgound nothing for...
0
by: Hani Atassi | last post by:
I am developing a secured Web Service that only specific Windows role can access it. I have the following in the configuration file: <authentication mode="Windows" /> <identity...
0
by: BrianT | last post by:
I'm trying to build code that allows the computer name to be changed, then asks the user to reboot to make the change affective. I got the code working when logged in as the local computer...
8
by: =?Utf-8?B?QkRSaWNoYXJkc29u?= | last post by:
I am aware that is is possible to determine the web client computer name using DNS, i.e. invoke System.Net.Dns.GetHostEntry( System.Web.HttpRequest.UserHostAddress). However, this only seems to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.