I have a compiled binary for Linked list written in c. I placed the executable in /usr/bin/ as /usr/bin/app where app is the name of the executable. This was compiled using gcc.
Can anyone help me to invoke this (app) using a python script.
I have written a script below to do this but seems to give errors. I am very new to python and have very basic knowledge on this. I am just exploring pythons features.
Below is the script code:
#!/usr/bin/env python
import subprocess
proc = subprocess.Popen(['\usr\bin\app'],
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE
)
(out, err) = proc.communicate()
print out
Here are the errors:
Traceback (most recent call last):
File "./LinkedList.py", line 7, in <module>
stderr = subprocess.PIPE
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Thank you for your assistancce
'/usr/bin/app''\usr\bin\app'-->\usinpp, as falsetru mentioned use forward slashes.