Home › Forums › OS X Server and Client Discussion › Questions and Answers › dscl scripts – revisited
- This topic has 5 replies, 3 voices, and was last updated 14 years ago by
Joy.
-
AuthorPosts
-
May 17, 2010 at 7:03 pm #378605
Joy
ParticipantI’m still having some issues with my script. I’ve simplified things in hopes of figuring out where it’s going wrong.
The launchd works. The script works if I run it from command line with launchctl. My env is EXACTLY the same, both from command line and the launchd.
If I remove the “ENetAddress $macAddress”, the computer group gets added, without any problem, either from the launchd or command line, just no Ethernet address.
If I add the “ENetAddress $macAddress” it fails at the launchd, even though Console will show that it has read the record correctly and that it is there:
Here are the players:
Script:
**********
#!/bin/sh
macAddress=`/sbin/ifconfig en0 | /usr/bin/grep ‘ether’ | /usr/bin/sed “s/^[[:space:]]ether //” | cut -f1 -d ” “`
echo “$macAddress”
/usr/bin/dscl . -create /Computers/Desktop ENetAddress $macAddress
/usr/bin/dscl . -read /Computers/DesktopLaunchd:
*************
[code]
[/code]
Label
sh.attrsetup
Program
/Library/Scripts/Custom/attrsetup.sh
RunAtLoad
Console after the launchd has run:
5/17/10 2:09:06 PM sh.attrsetup[51] 00:1f:5b:ea:90:89
5/17/10 2:09:06 PM sh.attrsetup[51] AppleMetaNodeLocation: /Local/Default
5/17/10 2:09:06 PM sh.attrsetup[51] ENetAddress: 00:1f:5b:ea:90:89
5/17/10 2:09:06 PM sh.attrsetup[51] GeneratedUID: 5B5D58EA-6FCC-4E8A-A99E-673A7B734F52
5/17/10 2:09:06 PM sh.attrsetup[51] RecordName: Desktop
5/17/10 2:09:06 PM sh.attrsetup[51] RecordType: dsRecTypeStandard:ComputersNo errors are reported, but when I start up WGM, that Computer “Desktop” isn’t there and going to /var/db/dslocal/nodes/default/computers, shows it isn’t there either.
May 18, 2010 at 4:38 pm #378611Greg Neagle
ParticipantThat would seem to imply that some other process is deleting the Desktop computer record _after_ your script creates it, since your script echos back the results of dscl . read /Computers/Desktop, proving that the record has been created.
-Greg
May 18, 2010 at 4:50 pm #378612Joy
ParticipantOne would think that, but the only launchd I have running is that one, other then the system ones. If I remove the ENetAddress part, the record gets added successfully. It is only when it tries to populate the ENetAddress key that the script fails.
I posted the problem on the Apple forums and someone gave me a different way of getting the en0, by using a perl script and that works, using the exact same launchdaemon. Although it puts the MAC address in that field 4 times.
I’ve opened an incident with Apple in hopes of shedding some light on the problem.
May 20, 2010 at 5:13 pm #378618Greg Neagle
ParticipantI can’t imagine why the method you are using to get the MAC layer address would matter, but here’s how I currently do it in my equivalent script:
macAddress=`/sbin/ifconfig en0 | /usr/bin/awk ‘/ether/ {print $2}’`
-Greg
March 29, 2011 at 8:14 am #380586berrty
ParticipantI am sure a lot of people will be curious to know the answer to the issue you are having with the script!! It’s the first time I am coming across such a problem and was interested in the possible solutions and hope it works for you!! Hope you will keep updating on it!!
April 4, 2011 at 7:05 pm #380608Joy
ParticipantIf I remember correctly, it was a combination of a couple of things. First, the dubious permissions on my launchagent and then the ole’ typos got me.
Changed the launchagent to the right permissions, made sure my typing was correct and everything worked!
-
AuthorPosts
- You must be logged in to reply to this topic.
Comments are closed