Rogelio wrote: > I've got quite a few Perl scripts that I would like to leverage, and > I'd like to make some Python wrapper scripts for them. > > The Perl scripts shell into various network appliances, run certain > commands, and then output those commands into a file. > > I recently found out about the subprocess modules (including "call") > and am wondering what other Python libraries and modules I should > check out. Specifically, I need functions that will do the > following... > > 1) Take a big IP file and break it up into smaller chunks (e.g. 20 IP > addresses per file)
itertools.islice() > 2) Run the Perl script on those smaller IP files subprocess. If the script can read from stdin you may not need the intermediate file; use subprocess.Popen(..., stdin=PIPE).communicate(inputdata_as_a_string) instead. > 3) Run the Perl commands in parallel (to take less time) multiprocessing? Though your problem may be I/O-bound. > 4) Take the little logs and concatenate the files itertools.chain.from_iterable() > 5) Look for existence of certain strings in the logs with open(logfile) as f: for line in f: if some_string in line: # whatever If you know Perl you will not be completely puzzled when you have to switch to a regex. You'll rather make that switch to early ;) > I'm still playing with the subprocess.call command to make sure that > it calls everything okay. But I'm hoping someone can point me where > to look for functions that will make this an effective wrapper script. You sound like you are not completely satisfied with subprocess. What are you missing? -- http://mail.python.org/mailman/listinfo/python-list