Python to open command script file

Mike Driscoll kyosohma at gmail.com
Thu Dec 11 13:50:25 EST 2008


On Dec 11, 12:04 pm, dave rose <s_david_r... at hotmail.com> wrote:
> Hello all
>  I would like to know how to do the following.  I'd like to have a generic
> python program that the user will open a command-script file to do actions.
>
> So, my python program will get a list of servers, enumerate them within a
> checklistbox in wxpython.  Then I want to open a command-file that will run
> against each selected server that will look like this:
>
> ---------------------------SAMPLE------------------------
> copy abc.xyz from c:\source to u:\target
> copy all     from c:\source to u:\target
> unload netshld from server1
> -------------------------END SAMPLE----------------------
>
> (where I have a class serverfuncs, where I can:
> s = serverfuncs()
> s.unload('<module>', '<server>')
>
> Really, I can do all the actions, but I don't know how to trigger them from an
> independent script file.
>
> Thanks!
> -Dave

I usually use python's included shutil module for copying files and
directories. I think that would be a little more cross-platform
friendly. However, if you want to execute those commands above, try
using the subprocess module or os.system.

Mike



More information about the Python-list mailing list