help w/ putenv

czrpb nanotech at europa.com
Tue Dec 10 12:20:02 EST 2002


Thanks to Chad and Martin.

Unfortunately I must be stupid since I am still unable to get this working.

Code is:

    import sys,os

    value=sys.argv[1]

    os.environ["PWD"]=value

    os.system("printenv")

When I execute (linux, tcsh, python 2.2.1):

  %ltrace python putenv.py "hi mom" | & egrep -i 'putenv|pwd'

memcpy(0x0811f07c, "putenv", 6)                   = 0x0811f07c
memcpy(0x0811f3ac, "putenv", 6)                   = 0x0811f3ac
memcpy(0x08120674, "putenv", 6)                   = 0x08120674
memcpy(0x0812475c, "putenv", 6)                   = 0x0812475c
memcpy(0x08116074, "putenv", 7)                   = 0x08116074
strchr("PWD=/tmp", '=')                           = "=/tmp"
memcpy(0x0811723c, "PWD", 3)                      = 0x0811723c
memcpy(0x081327dc, "pwd", 3)                      = 0x081327dc
memcpy(0x081328f4, "pwd", 3)                      = 0x081328f4
memcpy(0x08110b1c, "putenv.py", 10)               = 0x08110b1c
strrchr("putenv.py", '/')                         = NULL
fgets("os.environ["PWD"]=value\n", 8192, 0x080fe648) = 0x0814ee98
strncpy(0x081152e8, ""PWD"", 5)                   = 0x081152e8
strchr("PWD"", '\\')                              = NULL
memcpy(0x0811bc44, "PWD", 3)                      = 0x0811bc44
memcpy(0x0811bdf4, "putenv.py", 10)               = 0x0811bdf4
vsnprintf("PWD=hi mom", 11, "%s=%s", 0xbfffec7c)  = 10
putenv(0x0811be64, 10, 0xbfffecb0, 0xbfffecb4, 1) = 0
system("printenv"PWD=/tmp

Notice on the last line (which is exactly as it appear on my
screen). PWD is still '/tmp'.

Ack!!

Quentin






More information about the Python-list mailing list