I used it with Platypus to create a application that I can push out to all the computers I manage. I'm also using with InstaDMG to create new system images.
#!/bin/bash
################################################################################
#Display IP Address and Hostname of Computer
#Written to be used with Platypus - http://www.sveinbjorn.org/platypus
#Written by Rusty Myers - rustymyers@gmail.com
################################################################################
################################################################################
#Variables
################################################################################
computername=`scutil --get ComputerName`
en0test=`ifconfig en0 | grep -q 'inet ' && echo en0`
en1test=`ifconfig en1 | grep -q 'inet ' && echo en1`
################################################################################
#Functions
################################################################################
function testinterface {
if [ "$en0test" == "en0" ]
then
activeinterface=en0
elif [ "$en1test" == "en1" ]
then
activeinterface=en1
else
activeinterface=None
fi
}
function displayip {
if [ "$activeinterface" == "None" ]
then
ipaddress="None"
else
ipaddress=`ipconfig getifaddr $activeinterface`
fi
}
function displaydialog {
echoserial=`/usr/bin/osascript << EOT
tell app "System Events"
Activate
display dialog "Your IP address is $ipaddress. Your computer name is $computername" buttons "OK" default button 1 with title "IP Address and Computer Name"
end tell
EOT`
echo $echoserial
}
################################################################################
#Run the Functions
################################################################################
testinterface
displayip
displaydialog
No comments:
Post a Comment