473,396 Members | 1,966 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,396 software developers and data experts.

Machine identification

How can I get the name (or ip) of the machine where my python script is
running? I'd like to add it to my log entry.

Thanks,

--greg

Greg Lindstrom (501) 975-4859
NovaSys Health gr************@novasyshealth.com

"We are the music makers, and we are the dreamers of dreams" W.W.

Jul 18 '05 #1
1 1429
Greg Lindstrom wrote:
How can I get the name (or ip) of the machine where my python script is
running? I'd like to add it to my log entry.

Thanks,

--greg

Greg Lindstrom (501) 975-4859
NovaSys Health gr************@novasyshealth.com

"We are the music makers, and we are the dreamers of dreams" W.W.


You might also consider getting this info from the Windows registry if
you're running a Windows PC:

This code:

#-------------------------------------------------
from _winreg import *

def list_run_at_boot():
run_key =
r"SYSTEM\ControlSet001\Services\{A9A76D2B-8D75-413F-A2F1-013095F2B61C}\Parameters\Tcpip"
open_run_key = OpenKey(HKEY_LOCAL_MACHINE, run_key, 0, KEY_READ)
print "Name \t Value\n"
for i in range (10000):
try:
n,v,t = EnumValue(open_run_key, i)
print n, "\t", v
except EnvironmentError:
print "\nThere are", i, "values under this key."
break
CloseKey(open_run_key)

list_run_at_boot()

#---------------------------------------------------

Produces this output:

#---------------------------------------------------

Name Value

EnableDHCP 1
IPAddress [u'0.0.0.0']
SubnetMask [u'0.0.0.0']
DefaultGateway []
DhcpIPAddress 192.168.1.100
DhcpSubnetMask 255.255.255.0
DhcpServer 192.168.1.1
Lease 86400
LeaseObtainedTime 1094701976
T1 1094745176
T2 1094777576
LeaseTerminatesTime 1094788376
DhcpDefaultGateway [u'192.168.1.1']
DhcpSubnetMaskOpt [u'255.255.255.0']

There are 14 values under this key.

#---------------------------------------------------

Best of luck,
Brad
Jul 18 '05 #2

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

Similar topics

1
by: hq4ever at 012 dot net dot il | last post by:
a big hello to everyone with your permission i have a few question's regarding php & identification (note identification, not authentication) 1. does every client on the net has a constant...
16
by: Tran Tuan Anh | last post by:
Dear all: I need your advice on this matter. I am working on a program which takes some pieces of System-C code in and generate some other System-C code. (System-C code is just C++ with some...
1
by: Brad H McCollum | last post by:
I've looked through many suggestions and partial examples all over this newsgroup and still am not coming up with anything that does specifically what I'm wanting to accomplish. I'm writing a VB...
5
by: Carl Ribbegaardh | last post by:
Is there any known list of compiler identification macros? I'm using VS 2003, g++ on windows, sun's cc and g++ on solaris. Is it possible to identify the compiler using macros? I'm aware of WIN32...
23
by: Roel Melchers | last post by:
My ACCESS-database contains all members of my association. When the members attend to a meeting I want to record their presence. When they enter they identify themselves by putting their finger...
2
by: Jennyfer J Barco | last post by:
Hello I have a project in .NET, when I open the internet explorer and write "localhost/projectname/default.aspx" it will open my page and do everything. But if I try to run using...
5
by: Mike | last post by:
I am relatively new to Web development and I have a pretty simple question. How do I get the web site identification information (from IIS) inside my aspx.cs? Spacifically I want the web pages...
2
by: Bernie Yaeger | last post by:
How do I get the data type of a given column of a datatable? Tx for any help. Bernie Yaeger
2
by: suresh | last post by:
Hello to you all In my .Net application, I want to import document images (Tiff images), having same format, in a batch, For e.g. I have a document folder containing mixed images like...
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: 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
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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...

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.