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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.