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

  • Home
  • SEARCH
  • 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 8641107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:26:32+00:00 2026-06-12T11:26:32+00:00

Task is to execute bash script from python script and let it execute on

  • 0

Task is to execute bash script from python script and let it execute on background, even if python script will finish. I need UNIX solution and i do not care if it will be not working on Win.

Python script :

#!/usr/bin/env python
import os, commands
command = '/usr/bin/ssh localhost "/home/gd/test/python/back.sh  "   '
print os.spawnlp(os.P_NOWAIT,command)
print "Python done"

/home/gd/test/python/back.sh :

#!/usr/bin/bash

/bin/echo "started"
/bin/sleep 80
/bin/echo "ended"

The issue is, when python script starts , i see PID of spawned process printed. But there is no process on background. When i use P_WAIT i see exit code 127 which means that command not found in the path. But i already provided all paths that already possible?
These scripts works perfectly with commands.getouput.

  • 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-06-12T11:26:33+00:00Added an answer on June 12, 2026 at 11:26 am

    Something like this should work

    #!/usr/bin/env python
    import os
    command = ['/usr/bin/ssh', 'ssh', 'localhost', '/home/gd/test/python/back.sh']
    print os.spawnlp(os.P_NOWAIT, *command)
    print "Python done"
    

    Note that it’s preferable to use the subprocess module here instead of spawn

    #!/usr/bin/env python
    from subprocess import Popen
    command = ['/usr/bin/ssh', 'localhost', '/home/gd/test/python/back.sh']
    print Popen(command)
    print "Python done"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to programmatically add an Execute SQL task from within a script task
I am relatively new to multi-threading and want to execute a background task using
Is there either a bash command or a Python library that will time the
Currently this is what I need to type to execute my task execute 'mytask'
Let's say I have a task execute. I want to know according to the
It's not possible to invoke the same rake task from within a loop more
Strangley, my AsyncTask will execute onPreExecute but not doInBackground() or onPostExecute() . Logcat has
I want to execute a task with whenever rails gem at every reboot like
I have an Execute SQL task (SQL 2008) where I'm using two SSIS variables
I get the error below when I try to execute a task with celery

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.