Running a .py file iteratively at the terminal
Cameron Simpson
cs at zip.com.au
Mon Jan 26 17:35:03 EST 2015
On 26Jan2015 13:10, varun7rs at gmail.com <varun7rs at gmail.com> wrote:
>Thanks a lot Mark but that would be a bit trivial. How can I run the same file multiple times? Or if I need to run two commands:
>srva at hades:~$ python NFV_nw_eu_v3_14_1_15.py --output eu_v3_14_1_15 --demand demands_v3_21_1_15.xml --xml nobel-eu.xml
>srva at hades:~$ python NFV_v3_7_10_14.py -l log --lp --xml eu_v3_14_1_15.xml
>
>repeatedly, how can I do that? Can I write a script to perform this function?If so, can you please help me with it?
>The first command generates an output file eu_v3 and the second file feeds it to the solver. This is what I intend to do multiple times. I hope I have explained it this time in a much better way. I'm sorry English is my second language and I have some problems in expressing myself at times.
Certainly you can script it. Write a tiny shell script (named "mygensolve.sh"
for the sake of example). Example (untested):
#!/bin/sh
python NFV_nw_eu_v3_14_1_15.py --output eu_v3_14_1_15 --demand demands_v3_21_1_15.xml --xml nobel-eu.xml
python NFV_v3_7_10_14.py -l log --lp --xml eu_v3_14_1_15.xml
Either make it executable ("chmod +rx mygensolve.sh") and run it like this:
./mygensolve.sh
or don't bother, and run it in an analogous fashion to your python commands:
sh mygensolve.sh
There are multiple paths forward from here if you have many runs with filenames
which can be enurated somehow.
Cheers,
Cameron Simpson <cs at zip.com.au>
The top three answers: Yes I *am* going to a fire!
Oh! We're using *kilometers* per hour now.
I have to go that fast to get back to my own time.
- Peter Harper <bo165 at FreeNet.Carleton.CA>
More information about the Python-list
mailing list