Dear Perl Monks: I'm having an interesting problem with Perl on OS X Mountain Lion, perl v5.10.1. I replaced a bash script called on-firstboot.sh with a Perl script called on-firstboot.pl that does a number of things to a newly imaged Mac such as set the machine host name. I am using system to make these calls to bash, like so:
#!/usr/bin/perl use strict; use warnings; # Declare dependencies use File::Slurp; ... other code here ... # Do system calls to set computer name @args = ("scutil --set ComputerName '$name'"); system(@args); @args = ("scutil --set HostName '$name'"); system(@args); @args = ("scutil --set LocalHostName '$name'"); system(@args); ... script continues...
The first two of these work just fine. The $name variable contains a MAC address, in this case:
3c0754131c6dThe third command above fails with this error:
SCPreferencesSetLocalHostName() failed: Invalid argumentIt's almost as if the first two commands get the variable $name contents correctly and the third gets an empty string.
Any ideas? Perhaps I need to escape some of these quote characters? I used single quotes to avoid a quoting issue. The commands at the Terminal in OS X work fine with the MAC address in question whether I use single quotes or double-quotes. The failure only happens in the Perl script.
Other system calls in the Perl script are working fine. Perhaps I should insert some sort of sleep command to pause between system calls? (How does one sleep in Perl?)
Cheers...
In reply to Strange system call failure in OS X by endor-moon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |