Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Strange system call failure in OS X

by endor-moon (Initiate)
on Feb 18, 2013 at 15:12 UTC ( #1019350=note: print w/ replies, xml ) Need Help??


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

Actually, this is the way I ended up doing these system calls due to its relative simplicity:

# Declare dependencies use File::Slurp; # Declare variables we'll be using my $name = ""; my @args = (); my $result = ""; # Set computer name based on MAC address of en0 my @entries = qx(ifconfig en0 | awk '/ether/ { gsub(":", ""); print \$ +2 }'); chomp(@entries); $name = $entries[0];


Comment on Re^2: Strange system call failure in OS X
Download Code
Re^3: Strange system call failure in OS X
by karlgoethebier (Vicar) on Feb 18, 2013 at 20:43 UTC

    Hi endor-moon and welcome,

    After bothering myself a bit with awk (i repressed the details) i decided to take the swiss katana. I'm assuming that you just want the mac address:

    #!/usr/bin/env perl + use strict; use warnings; my $mac = ( split " ", ( qx(ifconfig en0) )[2] )[1]; print qq($mac\n); __END__ Karls-Mac-mini:monks karl$ ./endor-moon.pl 2c:07:54:5e:3e:f0 # i faked this, really ;-)

    This works for me. Please note also that your code didn't output anything (for me).

    Btw, why do you load a module that you don't use (File::Slurp) as well as some variables (@args, $result)...or do i miss something?

    My best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019350]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2015-07-04 20:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls