Hi Bo, Thank you very much for all your help!! But I'm having some problems with the line of code you recommended:
if isinstance(cmd, types.StringTypes): cmd = cmd.split(' ') I'm getting the following error: NameError: global name 'types' is not defined As you instructed, I put in the beginning of the functon proc: def proc(cmd_in): cmd = cmd_in if isinstance(cmd, types.StringTypes): cmd = cmd.split(' ') os.chdir("/home/qauser/jerome") outFile = os.path.join(os.curdir, "output.log") outptr = file(outFile, "w") errFile = os.path.join(os.curdir, "error.log") errptr = file(errFile, "w") retval = subprocess.call(cmd, 0, None, None, outptr, errptr) errptr.close() outptr.close() if not retval == 0: errptr = file(errFile, "r") errData = errptr.read() errptr.close() raise Exception("Error executing command: " + repr(errData)) Am I missing some module you are referencing with "types"? Thanks again, Jerome >I think I find what is wrong here ! > >First , I run the program in windows , and it execute >well without any >error and execption . >Second , I run it in Linux and the error you provide >occured . > >And then I debug the script in Linux , and found that >below : >The subprocess.call method pass its arguments to the >Popen object and >then the later fork the process , in the python >library reference I >found that : > >args should be a string, or a sequence of program >arguments. The >program >to execute is normally the first item in the args >sequence or string, >but can be explicitly set by using the executable >argument. > > >If the first argument is a string , then the Popen >class assume it is >only the command without arguments , and if the first >argument is a >sequence , the Popen class >assume that the first elment in the sequence is a >command name and >others else are arguments for the command . >So , if you want to pass arguments to your shell , you >must pass the >call method a sequence instead of a command . >I add a clause in the begin of the function proc : > >if isinstance( cmd , types.StringTypes): >cmd = cmd.split(' ') > >and everything is OK ! > >And I also there is a function called >list2cmdline(args) , which will >be >called in the windows version of Popen , and it is >this function make >the program through in windows with no error . __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor