Skip to content

Instantly share code, notes, and snippets.

@krispayne
Last active April 28, 2016 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krispayne/b0ba3c0f3400a5f715aa to your computer and use it in GitHub Desktop.
Save krispayne/b0ba3c0f3400a5f715aa to your computer and use it in GitHub Desktop.
#!/bin/bash
# Provide user info about the computer
# Kris Payne
# run this shiz in a policy in Self Service. It will let the user copy their IP or Computer name for you.
# slower than >System Preferences>Network ? Yes. Easier to explain? Yes.
# Definitions
thisComputerName="scutil --get ComputerName | pbcopy"
thisIPAddress=$(ifconfig | grep "inet " | grep -v 127.0.0.1 | awk {'print $2'} | pbcopy)
CD="/Applications/Utilities/CocoaDialog.app/Contents/MacOS/cocoaDialog"
# Script
printIPAddress="$thisIPAddress"
dialogBox=$($CD msgbox --no-newline \
--title "Computer Information" \
--text "Please select an option below:" \
--button1 "Copy Computer Name" --button2 "Copy IP Address" --button3 "Cancel")
if [ "$dialogBox" == "1" ]; then
# Get the computer name from SCUtil and then copy it to the default clipboard
eval "$thisComputerName"
elif [ "$dialogBox" == "2" ]; then
# Get the IP Address from ifconfig and then copy it to the default clipboard
eval "$printIPAddress"
elif [ "$dialogBox" == "3" ]; then
# print a snarky message
echo "Nevermind"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment