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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:48:42+00:00 2026-06-08T01:48:42+00:00

I execute a command in python using subprocess.popen() function like the following: omp_cmd =

  • 0

I execute a command in python using subprocess.popen() function like the following:

omp_cmd = 'cat %s | omp -h %s -u %s -w %s -p %s -X -' %(temp_xml, self.host_IP, self.username, self.password, self.port)
xmlResult = Popen(omp_cmd, stdout=PIPE, stderr=STDOUT)

In the shell it runs fine without error, but in Python I get:

  File "/home/project/vrm/apps/audit/models.py", line 148, in sendOMP
    xmlResult = Popen(omp_cmd, stdout=PIPE, stderr=STDOUT)
  File "/usr/local/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/local/lib/python2.7/subprocess.py", line 1228, in _execute_child
    raise child_exception
  OSError: [Errno 2] No such file or directory

I searched the error but none of them solved my problem. Does anyone know what’s the cause of this issue?

  • 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-08T01:48:43+00:00Added an answer on June 8, 2026 at 1:48 am

    If you’re going to pass the command as a string to Popen and if the commands have pipes to other commands in there, you need to use the shell=True keyword.

    I’m not particularly familiar with the omp command, but this smells an awful lot like a useless use of cat. I would think that a better way to achieve this would be to:

    import shlex
    omp_cmd = 'omp -h %s -u %s -w %s -p %s -X %s' \
    %(self.host_IP, self.username, self.password, self.port, temp_xml)
    xmlResult = Popen(shlex.split(omp_cmd), stdout=PIPE, stderr=STDOUT)
    

    Or, if it’s not a useless use of cat (You really do need to pipe the file in via stdin), you can do that with subprocess too:

    import shlex
    omp_cmd = 'omp -h %s -u %s -w %s -p %s -X -' \
    %(self.host_IP, self.username, self.password)
    with open(temp_xml) as stdin:
        xmlResult = Popen(shlex.split(omp_cmd), stdin=stdin, 
        stdout=PIPE, stderr=STDOUT)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I execute the following shell command using the Python subprocess module? echo
To launch programs from my Python-scripts, I'm using the following method: def execute(command): process
I am using python's Call method in subprocess module to execute a sqlldr command
When I execute a python script using subprocess.Popen(script, shell=True) in another python script, is
I am trying to execute a simple git command using following python script. #!/usr/bin/python
I've currently got a Bash command being executed (via Python's subprocess.Popen ) which is
I'm writing a python application that has a glade gui. Using subprocess to execute
I am running mongoimport command using python commands module as status = utilities.execute(mongoimport) in
I'm having a strange issue when using subprocess.Popen.communicate(). For background, I want to execute
I am using subprocess.check_output from pythons subprocess module to execute a ping command. Here

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.