Autolaunch Webpage From Policy

rieck
New Contributor

Looking at https://jamfnation.jamfsoftware.com/discussion.html?id=5693, I created a script that opens a webpage of the URL I pass in. But, when I run it as a script from a login policy, the webpage will open for a brief moment, then close after the policy finishes.

My goal is to install software updates on login, and then open a "Readme" webpage (and leave it open) for the user to review.

Is there a preferred or suggested way I should do this?

Thanks for any input!

7 REPLIES 7

mm2270
Legendary Contributor III

Post your script perhaps? May be something in there that's causing it to close.

rieck
New Contributor

I've tried it a few ways.

- Just created an ongoing Login policy and put "open <url>" in the Run Command on the Advanced tab

- Script that accepts an URL parameter:

#!/bin/sh
echo "url_path is $4";
sudo open $4

- Updated the above script to use Applescript:
osascript -e 'tell application "Safari" to open location "www.google.com"'

It's like I need to have it run in a different process so it doesn't close right away.

mm2270
Legendary Contributor III

Seems to me either of those should work OK. So, the symptom is, the page opens in Safari or the default browser, then disappears? Does the application quit or is it just the open page that closes?
I don't have anything like this as a policy, but I can whip one up quick on a test box and see. What OS version is this being deployed to BTW? What JSS version?

jarednichols
Honored Contributor

what if you add a & at the end of the line to background it?

rieck
New Contributor

OS = 10.7.5
JSS = 8.6

Safari opens to the correct webpage for a split second, but once the login has "completed" it goes away (right before the desktop refreshes and dock loads for the user).

I tried the & (open "http://www.google.com" &), but it did not seem to work.

mm2270
Legendary Contributor III

Well, I'm getting rather mixed results on a 10.8.2 test Mac and JSS 8.6. Originally I was using the same osascript line you posted in the Run Command in a login policy. The Mac would open Safari after login and immediately go into the background. So the Google page was there, but I had to click on Safari to bring it to the front. I tried making a few adjustments, none of which worked. Now, trying the same command again on the same box I can get Safari to open Google and stay open (not go to the background) Odd. Not sure why it wouldn't work originally but is now.
I can try this out on a 10.7.5 Mac as well. I'm finding there are a lot of differences between 10.7 and 10.8 in how stuff works, or doesn't.
My thought on this may be that the policy is opening Safari as root right before login completes, and then vanishes once the user profile is loaded, or something like that. though as a login policy that shouldn't happen.

jagress
New Contributor III

If you run this as a policy, then it's run as root and the browser process runs as root. This doesn't seem like a good idea to me - and perhaps, as you've suggested, this is part of the problem? Here's what I do in my environment:

su - `ls -l /dev/console | awk '{print $3}'` -c "open http://www.google.com"

Since it's only one line, it doesn't even have to be a script. You can use the "Run Command" option under Advanced in the policy.