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 585593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:01:08+00:00 2026-05-13T15:01:08+00:00

I have been using subprocess.Popen successfully in the past, when wrapping binaries with a

  • 0

I have been using subprocess.Popen successfully in the past, when wrapping binaries with a python script to format arguments / customize etc…

Developing a nth wrapper, I did as usual… but nothing happens.

Here is the little code:

print command
p = subprocess.Popen(command, shell = True)
result = p.communicate()[0]
print vars(p)
return result

And here is the output:

/usr/bin/sh /tmp/run/launch.sh
{'_child_created': True, 'returncode': 0, 'stdout': None, 'stdin': None, 'pid': 21650, 'stderr': None, 'universal_newlines': False}

As you can see, the goal is to create a shell script setting up everything I need, and then executing it. I would prefer to use real python code, but unfortunately launch.sh call 3rd party shell scripts that I have no wish to try and replicate (though I’ve been insisting for a python api for over a year now).

The problem is that:

  • the shell script is not executed (it should spawn process and output some little things)
  • no python exception is raised
  • there is nothing in the p object that indicates that an error occurred

I have tried check_call without any success either…

I am at a loss regarding what I should do, and would be very glad if someone could either point my mistake or direct me toward resolution…

EDIT:

  • Trying to run this on Linux (sh)
  • shell is necessary for variable substitution in the scripts invoked

EDIT 2:

Following badp suggestion, I tweaked the code and added

subprocess.Popen('ps', shell = True).communicate()

Right after p = ... line that creates the process, here is the output:

/usr/bin/sh /tmp/run/launch.sh
  PID TTY          TIME CMD
29978 pts/0    00:00:01 zsh
 1178 pts/0    00:00:01 python
 1180 pts/0    00:00:00 sh <defunct>
 1181 pts/0    00:00:00 ps
None

Apparently the process is launched (even though <defunct>) and one should also note that I have a little problem passing the parameters in…

Thanks.

  • 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-13T15:01:09+00:00Added an answer on May 13, 2026 at 3:01 pm

    I’ve finally found the answer to my question, thanks to badp and his suggestions for debugging.

    From the python page on the subprocess module:

    The executable argument specifies the program to execute. It is very seldom needed: Usually, the program to execute is defined by the args argument. If shell=True, the executable argument specifies which shell to use. On Unix, the default shell is /bin/sh. On Windows, the default shell is specified by the COMSPEC environment variable. The only reason you would need to specify shell=True on Windows is where the command you wish to execute is actually built in to the shell, eg dir, copy. You don’t need shell=True to run a batch file, nor to run a console-based executable.

    Since I am on Linux and using shell=True, my command is in fact a list of arguments to be executed by executable, which defaults to /bin/sh. Thus the full command executed was: /bin/sh /usr/bin/sh /tmp/run/launch.sh… which did not work so well.

    And I should have used either:

    subprocess.Popen('/tmp/run/launch.sh', shell=True)
    

    or

    subprocess.Popen('/tmp/run/launch.sh', executable = '/usr/bin/sh', shell=True)
    

    It’s tricky that shell=True would actually modify the default executable value on Linux only…

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

Sidebar

Related Questions

I'm currently using os.popen() but have been recommended to use subprocess.popen() instead. Any ideas
I have been using Selenium Webdriver successfully with JAR downloaded from their pages or
I have been using this piece of script to load external .js files to
We have been using CruiseControl for quite a while with NUnit and NAnt. For
I have been using PHP and JavaScript for building my dad's website. He wants
I have been using Eclipse as an IDE for a short amount of time
I have been using Castle MonoRail for the last two years, but in a
We have been using Scrum for around 9 months and it has largely been
I have been using C# for a while now, and going back to C++
I have been using ASP.NET for years, but I can never remember when using

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.