1

I want to execute shell command "objdump" using python for my research work I have used subprocess.call("command") to execute linux command but its not working.

Sample code which i have tried is

import subprocess
subprocess.call("date")

after the execution

Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "C:\Python27\lib\subprocess.py", line 168, in call
 return Popen(*popenargs, **kwargs).wait()
 File "C:\Python27\lib\subprocess.py", line 390, in __init__
 errread, errwrite)
 File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
 startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
asked Mar 29, 2017 at 15:10
1
  • 1
    I am pretty sure that traceback is not from an Ubuntu system! Commented Mar 29, 2017 at 15:23

2 Answers 2

3

You must do this:

subprocess.call('date', shell=True)

Actually, Shell does allow you to access to global variable and programs that are in $PATH and your shell.

answered Mar 29, 2017 at 15:14
Sign up to request clarification or add additional context in comments.

Comments

0

Have you tried ?

import subprocess
subprocess.call("date", shell = True)

1 Comment

But when i am trying using IDLE its returning 0.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.