Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 861899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:03:14+00:00 2026-05-15T09:03:14+00:00

For the first time, I am asking a little bit of help over here

  • 0

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


EDIT

Following miax’s advice, I stopped using shell=True. Instead I took a look at the Python documentation for subprocess and used the following piece of code :

cmd = 'xen-create-image --hostname '+nom+' --memory '+memory+' --partitions=/root/scripts/part.tmp --ip '+ip+' --netmask '+netmask+' --gateway '+gateway+' --passwd'
args = shlex.split(cmd)
subprocess.call(args)

Sadly, it doesn’t change anything…


EDIT2

I have used the tip given by miax but I still get the above error… Here is the code that I have used.

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

This is really strange… The exact command works fine when I run it in the regular shell…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:03:14+00:00Added an answer on May 15, 2026 at 9:03 am

    Does the xen-create-image script start with a hashbang? That is, is the first line something like

    #!/bin/sh
    

    ? That is one thing to check. Another is that you can try to call your command as:

    cmd = ['/bin/sh', '-c', 'xen-create-image --hostname %s --memory %s --partitions=/root/scripts/part.tmp --ip %s --netmask %s --gateway %s --passwd' % (nom, memory, ip, netmask, gateway)]
    subprocess.call(cmd, shell=False)
    

    You might want to print cmd to verify this is the command you intend to run (i.e. check the substitutions).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first time asking for some help here although I've been lurking
It's my first time here asking for your help and knowledge! I have a
Its my first time asking here, i hope get help, and meanwhile, help you
this is my first time asking a question here. I tried to be well
first time post here. I was hoping someone could help me make custom SPARQL
I am new to Python and this is my first time asking a stackOverflow
it's i first time i'm asking here. Sorry if the answer is available already.
It's my first time asking here (I have visited the site several times, but
I am first time asking question here, sorry, but I can not find similar
this is my first time asking something here, so don't be too harsh on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.