|No such thing as a small change|
Wrap around an interactive python scriptby Kirsle (Pilgrim)
|on Jul 20, 2010 at 23:41 UTC||Need Help??|
Kirsle has asked for the wisdom of the Perl Monks concerning the following question:
Fellow monks, I have need of your wisdom.
I'm trying to write a Perl script that wraps around an interactive Python script (it's the "upload.py" for Google's code review service). My script needs to get the output given to the user so that it can parse out the issue URL generated by upload.py.
I was thinking I would just do something like this:
my $output = `/script/upload.py @ARGV`;
I was expecting that this would run upload.py and print what upload.py prints to the user's terminal so they can see it, and when they're prompted to fill out information, it would pass their input through to upload.py directly.
But the backticks don't let STDOUT sneak through to the terminal, so then I tried using system() with "tee" to copy the STDOUT to a file which my script could read after:
But this didn't work either. No output from upload.py was given on my terminal; it was obviously hanging, waiting for input, but didn't give any output unless I made the upload.py exit normally (i.e. answering "no" when it prompted me about svn files that aren't managed by svn at the beginning). It may be a line buffering issue in upload.py; how could I force autoflush on it if this is the case?