Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Dynamically Create a file

by starX (Chaplain)
on Aug 01, 2008 at 05:18 UTC ( [id://701594]=note: print w/replies, xml ) Need Help??


in reply to Dynamically Create a file

I see a couple places you're going wrong. First and foremost, system() returns the exit status of the command, not the commands output. If you want the output of "lin --help", you should run it as qx/$command/. Of course, qx// doesn't pay attention to STDERR, so if you're interested in capturing that, you should re-write the command as $command = "lin --help 2> $test";

2> is the shells way of redirecting STDERR to someplace else.

Try this on for size...

use strict; use warnings; $testCase = "testing"; my $test = "./$testCase.txt"; $command = "lin --help 2> $test"; my $result = `$command`; print $result;
Note the use strict; and use warnings; directives. Those are your friend. EDIT: I should probably mention that I used qx// rather than system() because the former will return a program's output, and the latter only returns the return status.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-18 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found