http://qs1969.pair.com?node_id=1065838

young_monk_love_perl has asked for the wisdom of the Perl Monks concerning the following question:

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