Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: running a cmd in background and capturing the output

by Laurent_R (Vicar)
on Oct 09, 2013 at 18:50 UTC ( #1057604=note: print w/ replies, xml ) Need Help??


in reply to running a cmd in background and capturing the output

If you need the output of the command in your program (you presumably do), then you have to wait for this command to complete and using back ticks is probably the best solution, even if it is arguable that this is not exactly background.


Comment on Re: running a cmd in background and capturing the output
Re^2: running a cmd in background and capturing the output
by PBeginner (Initiate) on Oct 10, 2013 at 05:21 UTC

    Thanks to All for the suggestions, but i tried this way and its working good.

    my $myproc = Proc::Simple->new(); $myproc->redirect_output ("/outcome1.txt"); $myproc->start(\&disk_use,"/usr/bin"); my $running = $myproc->poll(); ##to chk if process is still running. my $pid= $myproc->pid; my $bk_id1=$pid; sub disk_use { my $path=shift; my $total_usage=du("$path"); print "total disk uasge is $total_usage\n"; }

    Its working:)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (14)
As of 2014-07-22 15:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (117 votes), past polls