Re: [Tutor] help with running perl script that writes to a text file

2013-02-06 Thread Peter Otten
3n2 Solutions wrote:

 Hello,
 
 I want to automate the following manual process from DOS promp:
 
 c:/scripts/perlperl fix.pl base.gtx base.txt
 
 Here is my python script:
 
 path=c:/scripts/perl/
 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 
that.

I think the following should work:

with open(c:/scripts/perl/base.txt, w) as f:
subprocess.check_call(
[perl, 
 c:/scripts/perl/fix.pl, 
 c:/scripts/perl/base.gtx], 
stdout=f)



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with running perl script that writes to a text file

2013-02-06 Thread eryksun
On Tue, Feb 5, 2013 at 6:44 PM, 3n2 Solutions 3n2soluti...@gmail.com wrote:

 I want to automate the following manual process from DOS promp:

I agree with Peter's answer. I'd just like to add a generally useless
and pedantic comment about the habit of saying DOS prompt. The cmd
shell is a Win32 console application, unlike DOS command.com. On
64-bit Windows there isn't even a virtual DOS machine (NTVDM) to run
command.com. There, I feel better now. :)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with running perl script that writes to a text file

2013-02-06 Thread Alan Gauld

On 06/02/13 10:58, eryksun wrote:


and pedantic comment about the habit of saying DOS prompt. The cmd
shell is a Win32 console application, unlike DOS command.com.


Yes, but the problem is that Windows now has so many command prompts 
(cscript, cmd, power shell etc) that the Windows prompt

would be meaningless and the cmd prompt too awkward to say,
so the DOS prompt is both traditional and sufficiently specific making 
it the most easily understandable of the likely terms.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with running perl script that writes to a text file

2013-02-06 Thread eryksun
On Wed, Feb 6, 2013 at 12:47 PM, Alan Gauld alan.ga...@btinternet.com wrote:
 so the DOS prompt is both traditional and sufficiently specific making it
 the most easily understandable of the likely terms.

DOS prompt is a common idiom, but it bears mentioning now and then
that the OS is NT [1], not DOS. That's all; I know I'm being pedantic.

Officially the Windows command-line shell is called the command
prompt. I call it the shell [2] or command line. Unless someone says
PowerShell or 4NT, I assume it's cmd.

[1] Windows 8 is NT 6.2.9200
[2] Not the GUI shell, Explorer, which is set here:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Shell
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] help with running perl script that writes to a text file

2013-02-05 Thread 3n2 Solutions
Hello,

I want to automate the following manual process from DOS promp:

c:/scripts/perlperl fix.pl base.gtx base.txt

Here is my python script:

path=c:/scripts/perl/
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 using python 2.7 on windows 7

Thanks,
Tim
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] help with running perl script that writes to a text file

2013-02-05 Thread Alan Gauld

On 05/02/13 23:44, 3n2 Solutions wrote:


I want to automate the following manual process from DOS promp:

c:/scripts/perlperl fix.pl base.gtx base.txt


Use a DOS batch file, that's what they are there for.

If you are not doing any other processing Python is inefficient and 
overkill for this task. Unless you just want to learn how to use Popen I 
suppose...




path=c:/scripts/perl/
subprocess.call(['perl','fix.pl','base.gtx base.txt',path])


Do you get any error messages on the console?
How are you running the python script?

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor