Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^2: System() in list mode?

by 1337John (Initiate)
on Oct 18, 2011 at 14:38 UTC ( #932161=note: print w/ replies, xml ) Need Help??

in reply to Re: System() in list mode?
in thread System() in list mode?

What??? Of course it's the correct output for my code. But it's not what I want my code to do. Could you be so kind as to provide me with an example of appending to the PATH variable, then successfully running a script in a path with spaces in it, in one system() call?

Comment on Re^2: System() in list mode?
Replies are listed 'Best First'.
Re^3: System() in list mode?
by anneli (Pilgrim) on Oct 18, 2011 at 21:00 UTC


    Here I'm prepending $HOME/dir to PATH, and executing a program named "program name", which happens to be in /home/anneli/dir (i.e. the path I prepended):

    $ pwd /home/anneli $ ls -F ./dir/ program name* $ cat dir/program\ name #!/usr/bin/env perl print "It works!\n"; $ cat system('env', "PATH=$ENV{HOME}/dir:$ENV{PATH}", 'program name'); $ perl It works! $

    I hope this helps. We do the necessary expansion of HOME and PATH on our side, before sending them through to the (non-expanding) multi-argument system call.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2015-11-27 06:29 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (719 votes), past polls