Hi all
I'm having a few issues trying to get a Cocoa Dialog script to work. I'm basically asking for a few variables which a then want it to set the computername based on these variables but its failing.
Can anyone see where i'm going wrong?
!/bin/sh
Set CocoaDialog Location
CD="/Path/to/CocoaDialog.app/Contents/MacOS/CocoaDialog"
CD_APP="/Users/Shared/CocoaDialog.app"
CD="$CD_APP/Contents/MacOS/CocoaDialog"
last7ofserial=$system_profiler SPHardwareDataType | awk '/Serial/ {print $4}' | rev | cut -c -7 | rev
mac="$MAC"
Dialog to enter the Location and the create $COMPUTERNAME variable
location=$("$CD" standard-dropdown --string-output --title "Choose a Location" --height 150 --text "Location" --items "London" "New York" "Shanghai")
devicetype=$("$CD" standard-dropdown --string-output --title "Choose a Device Type" --height 150 --text "Device Type" --items "LT" "DT")
COMPUTERNAME=$location$devicetype$mac$last7ofserial
Set Hostname using variable created above
scutil –-set ComputerName $COMPUTERNAME
scutil –-set HostName $COMPUTERNAME
scutil –-set LocalName $COMPUTERNAME
Dialog to confirm that the hostname was changed and what it was changed to.
tb=`$CD ok-msgbox --text "Computer Name Changed!"
--informative-text "The computer name has been changed to $COMPUTERNAME"
--no-newline --float`
if [ "$tb" == "1" ]; then
echo "User said OK"
elif [ "$tb" == "2" ]; then
echo "Canceling"
exit
fi