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
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.

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

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.