Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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 with a Perl script called 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:


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?)


In reply to Strange system call failure in OS X by endor-moon

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?

    What's my password?
    Create A New User
    [Discipulus]: each node has 2 descendants only: can i just compose hash keys usinng coords?
    [karlgoethebier]: Discipulus: you shouldn't smoke turkish spices before noon
    [Discipulus]: karl you says the same of my mom: in your place I'd been
    [Discipulus]: preoccupied.. ;=)
    Discipulus stopped with turkisk spices anyway.. but better hashes than arrays!
    [oiskuu]: Discipulus, from the edge or from the top?
    [Discipulus]: oiskuu from the top aka 0-0 coords

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (10)
    As of 2018-03-19 10:57 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (239 votes). Check out past polls.