Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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:

3c0754131c6d

The third command above fails with this error:

SCPreferencesSetLocalHostName() failed: Invalid argument

It'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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (11)
    As of 2014-07-29 13:16 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (217 votes), past polls