Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: System(), writing to a new file

by zork42 (Monk)
on Jul 18, 2013 at 07:18 UTC ( #1045004=note: print w/ replies, xml ) Need Help??


in reply to System(), writing to a new file

I am not sure about this, but are you able to redirect the output?
system("sort somefile.txt >somefile2.txt") or die;
If I've remembered my unix syntax, the following will send any error messages (on STDERR) to the file "error.txt"
system("sort somefile.txt >somefile2.txt 2>error.txt") or die;
IIRC you must use the single argument version of system() for redirections to work. (I think the multiple argument versions bypass the shell.) I'd check this though!

Replies are listed 'Best First'.
Re^2: System(), writing to a new file
by zork42 (Monk) on Jul 19, 2013 at 15:11 UTC
    Oops!
    I saw there was no redirection in the OP's code. That's why I suggested redirection in my post.
    But I missed the sort filename > newfilename comment in the OP text.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2016-08-29 07:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (399 votes). Check out past polls.