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) };
- qx// is the generic form of `...`
- `...` passes a single string to the shell (except when perl is sure that a shell is not needed), so you have to handle an unknown shell with unknown behavior. Quoting is necessary to prevent shell injection, but quoting rules differ from shell to shell. See http://www.in-ulm.de/~mascheck/various/ to get an idea how different shells can behave.
- `...` does not die, eval won't catch any error in external programs, so eval is useless here.
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". ;-)
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
In Section
Seekers of Perl Wisdom