setting program name, like $0= in perl?

M

mh

I'm sure this is a FAQ, but I certainly haven't been able
to find an answer.

Is it possible to set the program name as seen by the
operating system or lower-level libraries?

I'm connecting to a database, and the runtime helpfully
sends some information to the server, such as username,
pid, and program name.

Unfortunately, all my python programs get the name
'/usr/bin/python', and I would like to force that to
be the names of the individual scripts.

Many TIA!
Mark
 
D

Daniel Fetchinson

I'm sure this is a FAQ, but I certainly haven't been able
to find an answer.

Is it possible to set the program name as seen by the
operating system or lower-level libraries?

I'm connecting to a database, and the runtime helpfully
sends some information to the server, such as username,
pid, and program name.

Unfortunately, all my python programs get the name
'/usr/bin/python', and I would like to force that to
be the names of the individual scripts.

I don't know the answer to your question but I would start by trying
to figure out what information is really sent to the db. I mean it is
probably an environment variable or something like that, and once you
figure out exactly what it is, you will know what variable to set.

Cheers,
Daniel
 
E

Emile van Sebille

On 6/9/2009 1:06 PM (e-mail address removed) said...
I'm sure this is a FAQ, but I certainly haven't been able
to find an answer.

Is it possible to set the program name as seen by the
operating system or lower-level libraries?

I'm connecting to a database, and the runtime helpfully
sends some information to the server, such as username,
pid, and program name.

Unfortunately, all my python programs get the name
'/usr/bin/python', and I would like to force that to
be the names of the individual scripts.

If you include the shebang as first line and execute the script directly
I think it'll work.

---- test.py----
#!/usr/bin/python

import sys
print sys.argv[0]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top