new to Python - modules to leverage Perl scripts?
Cameron Simpson
cs at zip.com.au
Mon May 7 03:37:21 EDT 2012
On 07May2012 09:16, Peter Otten <__peter__ at web.de> wrote:
| 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...
[...]
| > 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.
If he stuffs the inputs into TemporaryFiles he can attach them to
subprocess.Popen() stdin and just not wait. Dispatch them all and collect
afterwards. Only tempfile and subprocess needed; no need for
communicate.
Cheers,
--
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/
One of the most important things you learn from the internet is that there is
no 'them' out there. It's just an awful lot of 'us'. - Douglas Adams
More information about the Python-list
mailing list