Hi Guys,
So i have a shell script that "should" accommodate for OSX 10.6 -10.8
When I push it through casper to a 10.6.8 box it runs likes like a champ, but i've recently tried pusing it to a 10.8.4 box and it fails with a syntax error.
That being said, if move the script locally onto the 10.8 system, run a chmod and then execute the script in terminal it ran beautifully. The only thing i noticed when I ran it locally was that it prompted for admin credentials. Not in the script, but it actually pormpted a "wants to make changes to your computer" box.
Here is what i'm using... would REALLY appreciate any input on this!
#!/bin/sh
# setSearchDomains.sh -- Set a search domain for a specified network interface
#
# SYNOPSIS
# sudo setSearchDomains.sh
# sudo setSearchDomains.sh <mountPoint> <computerName> <currentUsername> <networkInterface>
# <searchDomains>
#
# If the $networkInterface parameter is specified (parameter 4), this is the Network Interface for
# which the search domains will be set. The expected values for the $networkInterface parameter can
# be found by running the command:
#
# networksetup -listallnetworkservices
#
# If the $searchDomains parameter is specified (parameter 5), this is the search domain that will
# be set.
#
# If no parameter is specified for parameters 4 and 5, the hardcoded value in the script will be
# used.
#
# DESCRIPTION
# This script will set a search domain in the network settings for whichever network interface has
# been specified.
#
#
# DEFINE VARIABLES & READ IN PARAMETERS
#
####################################################################################################
# HARDCODED VALUES ARE SET HERE Example Interfaces are Ethernet 1, Ethernet 2, Thunderbolt Ethernet (rMBP), USB Ethernet etc basically whatever your Network Type shows in Sys Prefs
networkInterface="Wi-Fi"
searchDomains="Company.corp, americas.company.corp, europe.company.corp, sea.company.corp, asia.company.corp"
# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 4 AND, IF SO, ASSIGN TO "networkInterface"
if [ "$4" != "" ] && [ "$networkInterface" == "" ];then
networkInterface=$4
fi
# CHECK TO SEE IF A VALUE WAS PASSED IN PARAMETER 5 AND, IF SO, ASSIGN TO "searchDomains"
if [ "$5" != "" ] && [ "$searchDomains" == "" ];then
searchDomains=$5
fi
####################################################################################################
#
# SCRIPT CONTENTS - DO NOT MODIFY BELOW THIS LINE
#
####################################################################################################
if [ "$networkInterface" == "" ]; then
echo "Error: No network interface has been specified."
exit 1
fi
if [ "$searchDomains" == "" ]; then
echo "Error: No search domains have been specified."
exit 1
fi
OS=`/usr/bin/defaults read /System/Library/CoreServices/SystemVersion ProductVersion | awk '{print substr($1,1,4)}'`
if [[ "$OS" < "10.5" ]]; then
echo "Setting search domains for OS $OS..."
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup -setsearchdomains "$networkInterface" "$searchDomains"
else
echo "Setting search domains for OS $OS..."
/usr/sbin/networksetup -setsearchdomains "$networkInterface" "$searchDomains"
fi
Here is what i'm getting from the log
Script Result: /private/tmp/setSearchDomains-WiFi copy.sh: line 1: syntax error near unexpected token `newline'
/private/tmp/setSearchDomains-WiFi copy.sh: line 1: `
