Posted on 09-10-2013 01:07 PM
I'm setting up a Self Service script to pop up a window displaying the hostname and IP addresses. Here's what I have:
#!/bin/bash
compname=`scutil --get ComputerName`
wifi_IP=`networksetup -getinfo Wi-Fi | grep "IP address" | head -n 1`
ethernet_IP=`networksetup -getinfo Ethernet | grep "IP address" | head -n 1`
thunderbolt_IP=`networksetup -getinfo Thunderbolt Ethernet | grep "IP address" | head -n 1`
display_IP=`networksetup -getinfo Display Ethernet | grep "IP address" | head -n 1`
if [[ `networksetup -listallnetworkservices | grep Wi-Fi` == "Wi-Fi" ]]; then
wifimsg="Wireless $wifi_IP"
else
wifimsg="--------"
fi
if [[ `networksetup -listallnetworkservices | grep -o Ethernet | head -n 1` == "Ethernet" ]]; then
ethernetmsg="Ethernet $ethernet_IP"
else
ethernetmsg="--------"
fi
if [[ `networksetup -listallnetworkservices | grep Thunderbolt Ethernet` == "Thunderbolt Ethernet" ]]; then
thunderboltmsg="Thunderbolt Ethernet $thunderbolt_IP"
else
thunderboltmsg="--------"
fi
if [[ `networksetup -listallnetworkservices | grep Display Ethernet` == "Display Ethernet" ]]; then
displaymsg="Display Ethernet $display_IP"
else
displaymsg="--------"
fi
Desc="Mac Hostname: $compname
$wifimsg
$ethernetmsg
$thunderboltmsg
$displaymsg"
MSG=$( echo "$Desc" )
/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper -windowType utility -heading "Computer Information" -description "$MSG" -button1 "OK"
exit 0
For some reason, I only see the first 2 -------- lines. displayMessage shows the full text, but I like the look of jamfHelper better.
Is there a limit to how big the jamfHelper dialog can be? I may resort to doing a displayMessage, or even an osascript display dialog.
Posted on 09-10-2013 01:19 PM
There is a limit to how much text jamfHelper can display and I've run into it before. I can't recall what the cutoff is though. How many lines or characters are you seeing in the message and how many are you expecting to see?
It could also be something in how your message variable is being set up. Sometimes some characters can cause it to think its hit the end of the text to display, but I haven't looked at your script closely enough to see if that's what's actually happening.
You may also want to look at cocoaDialog, as it has no such limits on how much text it can display and you can have even more precise control over the size and position of the dialog.
Posted on 09-10-2013 01:41 PM
Thanks mm2270. I'm trying to get 6 lines to display. They aren't really that long. Once it gets to the 3rd line it seems to stop there. Here's what should display:
Mac Hostname: MyHostname
--------
--------
Ethernet IP address: ###.###.###.###
--------
--------
and the other lines would fill in with Wireless, Thunderbolt Ethernet, or Display Ethernet if they were connected.
Is cocoaDialog builtin to OS X? I'll take stab at that.
Posted on 09-10-2013 01:52 PM
No, cocoaDialog isn't built in, You'd have to grab it from the Github page and package and deploy it to your clients. We put ours in the same place as jamfHelper.app (/Library/Application Support/JAMF/bin) and can call it whenever we need with policy scripts or other functions.
Just FYI, I did a very quick test and looks to me like adding a heading in is what causes most of the other lines to get cut off. Without it I was just about able to get 6 lines to display, but there is definitely a fix height to any jamfHelper window, so you will run into it, no matter if a heading is there or not.
Posted on 09-11-2013 05:28 AM
+1 to cocoa dialog. I added it to our build sequence along with dockutil. I like jamfHelper but it is limited in how much text it can display, and button function, etc.