View Single Post
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: redirect output of a CMD to file

 
0
  #4
Nov 20th, 2008
Hey there,

I found this on the web - it's specific to perl, but you can use the /C flag to capture that output from the exe file, I believe. If it works, thank the guy who figured it out

http://community.activestate.com/for...ut-system-call

Bug in Windows shell redirection and file associations
mmmann | Tue, 2008-08-12 08:14

You cannot redirect or pipe output using cmd.exe when the Perl program is started using the Windows' file association(s) and the Perl program executes programs using open3 or system. Using a test.pl program that merely does a system(qw(netstat -an)), try this:

C:> perl test.pl > out # works
C:> test.pl > out # broken, and leaves "zombie" netstat executable

The work-around is to alter the file association:

Windows-E to bring up an explorer window
Tools -> Folder Options
Go to the [File Types] tab
Type 'PL' to move list box to PL extension
Click [Advanced]
Click [Edit] to edit the Open command

The "application used to perform action" reads, by default:

"C:\Perl\bin\perl.exe" "%1" %*

Overwrite it with the following:

C:\WINDOWS\System32\command.com /C C:\Perl\bin\perl.exe "%1" %*

...i.e. add command.com /C at the beginning and remove the double quotes around the perl executable. Yes, command.com, not cmd.exe.

This appears to be fixed in Vista.

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote