Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Output redirection problem in Windows ActivePerl

by Corion (Patriarch)
on Sep 20, 2010 at 12:15 UTC ( [id://860826]=note: print w/replies, xml ) Need Help??


in reply to Output redirection problem in Windows ActivePerl

Backslashes in double quotes behave differently from backslashes in single quotes. Your \t in c:\temp gets interpreted as tab character in double quoted strings. See perlop.

The solution is to check the command you're about to execute:

my $cmd = "ping $_ >c:\temp\log.txt"; print "About to run [$cmd]\n"; system($cmd) == 0 or die "Couldn't run [$cmd]: $!/$?/$^E";

In the short run, doubling all backslashes will do what you want:

my $cmd = "ping $_ >c:\\temp\\log.txt"; print "About to run [$cmd]\n"; system($cmd) == 0 or die "Couldn't run [$cmd]: $!/$?/$^E";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://860826]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-19 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found