Hi

I have some python file.i runs these file one by one as below on unix server.

python f4761sk3.py
python f4761sk2.py
python f4761sk1.py
python f4761se3.py
python f4761se2.py
python f4761se1.py
python f4761pl3.py
python f4761pl2.py
python f4761pl1.py
python f4761no3.py
python f4761no2.py
python f4761no1.py
python f4761nl3.py
python f4761nl2.py
python f4761nl1.py
python f4761ie3.py
python f4761ie2.py
python f4761ie1.py
python f4761hu3.py
python f4761hu2.py
python f4761hu1.py
python f4761gb3.py
python f4761gb2.py
python f4761gb1.py
python f4761fi3.py

This process takes so much time.
Is it possible to run these file together through any script so that all file run automatically one after another.

Is it possible ?then how?

please provide the code if possible...

Regards
Neeraj kumar

Recommended Answers

All 6 Replies

I suggest a shell script

#!/bin/sh
python f4761sk3.py
python f4761sk2.py
python f4761sk1.py
python f4761se3.py
python f4761se2.py
python f4761se1.py
python f4761pl3.py
python f4761pl2.py
python f4761pl1.py
python f4761no3.py
python f4761no2.py
python f4761no1.py
python f4761nl3.py
python f4761nl2.py
python f4761nl1.py
python f4761ie3.py
python f4761ie2.py
python f4761ie1.py
python f4761hu3.py
python f4761hu2.py
python f4761hu1.py
python f4761gb3.py
python f4761gb2.py
python f4761gb1.py
python f4761fi3.py

and make this file executable.

commented: How to make it executable ? +0
import os

base = 'f4761'
Series = ['sk','se','pl','no','nl','ie','hu','gb','fi']
for series in Series:
    for xx in reversed(range(1,4)):
        file = base+series+str(xx).strip()+".py"
        os.system( file )

Python is always the right answer.

import os

base = 'f4761'
Series = ['sk','se','pl','no','nl','ie','hu','gb','fi']
for series in Series:
    for xx in reversed(range(1,4)):
        file = base+series+str(xx).strip()+".py"
        os.system( file )

Python is always the right answer.

Don't use "file" as variable name, use something other (ffile etc).

All these scripts will start a new python instance. I think there must be a well developed scripts that check to see that a script instance has termiated before starting a new one.

However maybe the poster does not need this. just give a shout if needed :)

This is true (previous post re: using file as a variable, also agreed). Previously, our poster was executing these by hand, so a new instance of python isn't really that much of a hardship. Honestly, if the Python program have a consistent function to call, we probably could have called it directly.

In that vein, we could do what I really enjoy; writing programs that write programs. Generate a python script with the loops, then execute that program. It would be written to import each file and invoke its main program.

@Karthik_4 in linux, the command to make the file myscript executable is

chmod +x myscript
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.