Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

system command - redirect also the STDERR to a file

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Joined
Feb 6, 2002
Messages
1,851
Location
IL
HI,

Running an AciveState on W2K,I dod not manage to redirect also the STDERR to a file.STDOUT is in the file "COPY",STDERR is not.

system("xcopy /f /y $_ >COPY 2>&1") ;

Appreciate any help.

Long live king Moshiach !
 
did you try:

system("xcopy /f /y $_ >COPY 2>COPY") ;

- Kevin, perl coder unexceptional!
 
Interesting... I'm running Active state on a win2k machine as well, and MoshiachNow's command worked for me, placing both stdout and stderr in the same file. I tried his command exactly which worked, and also tried a simple command like:
Code:
system("dir asdf >results 2>&1");

where asdf didn't exist, and results contains both err and out.

I don't know if Kevin's solution works, because that would be 2 streams writing to the same file at the same time... Maybe some versions can handle it though - mine won't
 
HI,

Ended up writing to 2 files:

system("xcopy /f /y $_ >COPY 2>COPY1") ;

Maybe the whole issue is due to the usage of the pp converter to exe ?

Thanks

Long live king Moshiach !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top