[Tutor] help with running perl script that writes to a text file
__peter__ at web.de
Wed Feb 6 11:12:54 CET 2013
3n2 Solutions wrote:
> I want to automate the following manual process from DOS promp:
> c:/scripts/perl>perl fix.pl base.gtx >base.txt
> Here is my python script:
> subprocess.call(['perl','fix.pl','base.gtx >base.txt',path])
> I also tried this alternative:
> subprocess.Popen(['perl','fix.pl','base.gtx >base.txt',path]) #same
> result from this method.
> The above script generates the base.txt file but has no content in it.
> any ideas as to why the resulting text file is empty? Am I using the
> correct python commands to run the above manual process?
I'm surprised that base.txt is generated at all, I'd expect fix.pl to look
for a file named "base.gtx >base.txt" and complain when it doesn't find
I think the following should work:
with open("c:/scripts/perl/base.txt", "w") as f:
More information about the Tutor