Problem executing script using Python and subprocces.call yet works in Bash

Posted by Antoine Benkemoun on Stack Overflow See other posts from Stack Overflow or by Antoine Benkemoun
Published on 2010-05-25T22:16:34Z Indexed on 2010/05/25 22:21 UTC
Read the original article Hit count: 325

Filed under:
|
|

Hello,

For the first time, I am asking a little bit of help over here as I am more of a ServerFault person.

I am doing some scripting in Python and I've been loving the language so far yet I have this little problem which is keeping my script from working.

Here is the code line in question :

subprocess.call('xen-create-image --hostname '+nom+' --memory '+memory+' --partitions=/root/scripts/part.tmp --ip '+ip+' --netmask '+netmask+' --gateway '+gateway+' --passwd',shell=True)

I have tried the same thing with os.popen. All the variables are correctly set.

When I execute the command in question in my regular Linux shell, it works perfectly fine but when I execute it using my Python scripts, I get bizarre errors. I even replaced subprocess.call() by the print function to make sure I am using the exact output of the command.

I went looking into environment variables of my shell but they are pretty much the same... I'll post the error I am getting but I'm not sure it's relevant to my problem.

Use of uninitialized value $lines[0] in substitution (s///) at /usr/share/perl5/Config/IniFiles.pm line 614. Use of uninitialized value $_ in pattern match (m//) at /usr/share/perl5/Config/IniFiles.pm line 628.

I am not a Python expert so I'm most likely missing something here.

Thank you in advance for your help,

Antoine

© Stack Overflow or respective owner

Related posts about python

Related posts about subprocess