I have a command like that spins off some calculations and stores some output in a folder. So, I have this command that works on the bash command (in Ubuntu).
/home/usr2/AXE/prog1.exe -k 1 -m /home/usr2/AXE/config.txt
However, I would like to "call" this from inside a python program.
The final idea is to generate lots of serial processes of this nature inside python.
/home/usr2/AXE/prog1.exe -k 1 -m /home/usr2/AXE/config.txt
/home/usr2/AXE/prog1.exe -k 2 -m /home/usr2/AXE/config.txt
/home/usr2/AXE/prog1.exe -k 3 -m /home/usr2/AXE/config.txt
...
...
/home/usr2/AXE/prog1.exe -k 2000 -m /home/usr2/AXE/config.txt
SO FAR
import os
os.system('"/home/usr2/AXE/prog1.exe -k 1 -m /home/usr2/AXE/config.txt"')
This gives me command line output of Out[11]: 32512, but the output file is not produced in the requisite folder.
What am I doing wrong?
P.S. No idea about Bash programming. But would be interested in Bash solutions as well.
os.system()is old, hard-to-use-correctly, and is replaced by thesubprocessmodule. Also, you're using too many quotes -- don't put literal quotes inside your syntactic quotes unless doing so results in a command you could actually pass to a shell with those literal quotes included.for ((i=1; i<=2000; i++)); do /home/usr2/AXE/prog1.exe -k "$i" -m /home/usr2/AXE/config.txt; done