Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

'system @list' in background?

by vkon (Curate)
on Jan 19, 2014 at 18:30 UTC ( #1071202=perlquestion: print w/replies, xml ) Need Help??
vkon has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

according to documentation,
I can issue

system("cmd foo bar&")

so the process runs in background.

is this possible the same but when I specify 'system @list' syntax?

Thanks in advance!

Replies are listed 'Best First'.
Re: 'system @list' in background?
by Anonymous Monk on Jan 19, 2014 at 22:22 UTC

    The system @list form bypasses the shell, so running the process in the background is possible, but it takes a lot more code if you want to implement it yourself. Before you try to implement this yourself it's probably much easier to just use a module like IPC::Run.

Re: 'system @list' in background?
by ikegami (Pope) on Jan 20, 2014 at 15:22 UTC
    system('cmd foo bar &')
    is short for
    system('/bin/sh', '-c', 'cmd foo bar &')

    But you're surely asking to pass cmd, foo and bar as separate args.

    We can use sh to build the command:

    system('/bin/sh', '-c', '"$@" &', 'dummy', $prog, @args);

    Or we can use a Perl module to build the command:

    use String::ShellQuote qw( shell_quote ); system(shell_quote($prog, @args) . ' &'));
Re: 'system @list' in background?
by Anonymous Monk on Jan 20, 2014 at 02:46 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1071202]
Approved by hdb
help
Chatterbox?
[LanX]: but I don't understand the question...
[GotToBTru]: okay, I see what it does
[GotToBTru]: you;ve answered it .. the expression is meant to be evaluated as written, it is not a symbol for a special operation
[LanX]: '&;@' is a parsing error
[GotToBTru]: by itself, yes, but used in sub pre(&;@) not so
[LanX]: &; is interpreted as a function call, but the @ has no meaning
[LanX]: OH
[LanX]: you are talking about signatures?
[GotToBTru]: yes, it turns out I am
[LanX]: http://perldoc. perl.org/perlsub. html#Prototypes

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2017-01-18 21:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (164 votes). Check out past polls.