http://www.perlmonks.org?node_id=1019047


in reply to Re: Strange system call failure in OS X
in thread Strange system call failure in OS X

eval { $result = qx(scutil --set LocalHostName $name) };

Read the "Safe Pipe Opens" section of perlipc for a secure replacement for `...`.

The shell problem is also present in the single argument versions of system and exec, so make sure to use the multi-argument versions, which don't have this problem.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^3: Strange system call failure in OS X
by karlgoethebier (Abbot) on Feb 16, 2013 at 19:19 UTC

    Mmh...?

    #!/usr/bin/env perl + eval { qx(nose --cuke) || die qq(shit: $!\n) }; print qq(Trapped this $@) if $@; __END__ Karls-Mac-mini:monks karl$ ./nose.pl Trapped this shit: No such file or directory

    Update: I always thought that it isn't a bad idea to wrap a call to a subshell into a eval block. And i don't know what is generic with qx. It's just the same as backticks, isn't it? Just a subshell.

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»