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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hi, i am a new member,

and as the question's title says i would like to execute a system call but instead getting the display of the command in the console i want to have a .txt file created or be able to get the output of the file created by this system call.

So i tried :

$var = `<my command> 2>&1 1>/dev/null`;

i still had the output of the command, then

open FILE, "<my command> 2>&1 1>/dev/null" or exec(); die $!;

and system("<my command> 2>&1 1>/dev/null");

i still had the output of the command in the console. I started perl a week ago and i think i am taking the wrong approach on this problem, could you please help me ?

*update* changed the question's name

I done additional research on the command i would like to run, and found out that the command write a file that i can use so the retrieving output problem is solved but i still can cancel the display of the command

Additionally as X-mas is coming I'd like to know what books or tutorials should I read about using perl to monitor and manage external process on Linux or something nice to start. Thank you.

Regards

Thank you all for your answers i now understand my mistakes

Actually, my command couldn't execute without outputting a display so I did it in a separate terminal ... The structure i used for this purpose is :

sub sigtrap() { if(defined($pid) && ! ($pid == 0)){ killfam 'TERM', ($pid); } print "\n"; exit(1) } $pid = fork(); if($pid == 0){ #print "DEBUG - I am the child pid : $$ \n"; qx/my command running in background 2>&1 1>\/dev\/null/; sleep 10; exit(0); } sleep 15; #use the command's output file to get the results

In reply to Do not display the command result in the console (updated) by young_monk_love_perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-16 04:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found