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
-
1I am pretty sure that traceback is not from an Ubuntu system!ergysdo– ergysdo2017年03月29日 15:23:58 +00:00Commented Mar 29, 2017 at 15:23
2 Answers 2
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
RaminNietzsche
2,8111 gold badge24 silver badges37 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Have you tried ?
import subprocess
subprocess.call("date", shell = True)
1 Comment
sanjay.sharma
But when i am trying using IDLE its returning 0.
default