running a program via exec*
mylinuxboxroot
aries at bitstream.net
Fri Feb 22 02:15:29 EST 2002
More information about the Python-list mailing list
Fri Feb 22 02:15:29 EST 2002
- Previous message (by thread): running a program via exec*
- Next message (by thread): running a program via exec*
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Rajarshi Guha <rxg218 at psu.edu> wrote in message news:a54294$l0e at r02n01.cac.psu.edu... > Hi, > this is somewaht related to my earlier post. When I use execl(progname) > it seems to work. However it always looks for the progrma in the current > directory. Is there any way to specify the path from the environment > without having to type out the path to the program itself? > > TIA, > > -- > ------------------------------------------------------------------- > Rajarshi Guha | email: rajarshi at presidency.com > 417 Davey Laboratory | web : http:// www.jijo.cjb.net > Dept. Of Chemistry | ICQ : 123242928 > Pennsylvania State University | AIM : LoverOfPanda > ------------------------------------------------------------------- > GPG Fingerprint: DCCB 4D1A 5A8B 2F5A B5F6 1F9E CDC4 5574 9017 AF2A > Public Key : http://pgp.mit.edu/ > ------------------------------------------------------------------- > All syllogisms have three parts, therefore this is not a syllogism. yep Yes, of course there is a way, If I understand your question correctly you are going to run a script FROM in some directory lets say the directory is named on unix /mypycode/mypydir on windows c:\mypycode\mypydir Now in the script file you want the script to execute a program which is in some other directory on your system lets say its named myprogdir. And lets say the actual path to that location is on unix /stuff/junk/myprogdir on windows c:\stuff\junk\myprogdir and the program name you want to execute is some simple program that shows the date lets say its named showdate and its located in the myprogdir directory the program below --- #put she bang here for unix posix systems import os import string #for the str() built in method #---import sys #operating system hard drive variables myname = os.name print "the os is: ", myname if os.name == 'posix': myrootdir = "/" elif os.name == 'nt': myrootdir = "c:\\" else: print "This machine OS is something other than nt or posix\n" print "the root dir is: ",myrootdir #will be used to show me what current directory I am in wheredir = os.getcwd() #list the files in this directory mydirfiles = os.listdir(os.curdir) print "my current dir is: ", wheredir print "the file listing is: \n", mydirfiles print "##########\n" # change to the other programs directory location thedir = os.path.join(str(myrootdir),'stuff', 'junk', 'myprogdir') os.chdir(thedir) print "CHANGED- NOW my current dir is: ", thedir #list the files in this directory showfiles = os.listdir(os.curdir) print "CHANGED- NOW the file listing is: \n", showfiles print "##########\n" #--now launch your program file named showdate os.system("showdate")
- Previous message (by thread): running a program via exec*
- Next message (by thread): running a program via exec*
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list