Skip to main content

This has probably been brought up before but I couldn't find anything in
the archives. Anyway, I have a policy setup to run two scripts that need
to be run in a certain order. They are named in alphabetical order.
However, there is no consistency to which order they really run. If you
edit the policy they are listed in the proper order, but if you look at
the policy "plan" the order is opposite. When I actually run the policy
on a computer they run in random order. So, what is the proper way to
get scripts to run in order?



Thanks



~ Ryan

just to be sure, are they both set to the same 'priority' of before, after
or at reboot?
If one was set to after, it would run second, even if the name was
alphabetically first, I believe.



ben janowski
Senior Macintosh Support Technician
Kohl's Mac Support Team
262.703.1396 | benjamin.janowski at kohls.com


Correct, scripts should run in alphabetical order, and follow the priority.


Yes, both are set to Before. The names are:



getLongestUser.php
getRealName.sh



I would just combine them but as you can see, one is PHP and the other is Bash.



~ Ryan


What I do is that I set up scripts as manual trigger policies, so that
in a parent script it executes them in order. That way I don't have to
worry about using numbers and letters to do the alpha numeric system of
priority.



So, for example:



#!/bin/bash



tons of parent commands



jamf policy -trigger myscript1



more unix commands



jamf policy -trigger myscript2



exit 0



So I execute the script when need be, or the command. I then
consolidate scripts with Casper features. Like for example my bind
script is not needed, as the Casper client can set BIND by smart group
and auto run data.


Ryan, you can call different languages with in the same script...



Try this



#!/bin/bash



my shell commands



#calling php
/usr/bin/php <<EOF



a bunch of php commands
EOF



last unix commands



exit 0



I do this all the time with in shell for other languages. Well, not
all the time, but sometimes.


Interesting, is there a way to pass variables between the two (in and out)? At this point I’ve been setting temp files with the data to pass back and forth. Thanks



~ Ryan


In, yes, out, no. But you can redirect output to a variable if you want...


Yes, in my post image script I call Apple Script and it uses shell
variables. Below you can see shell variables being input into a Apple
Script, also what you write in PHP can probably be translated into a
different language. I don't know a lot of PHP but if you could describe
what you want to accomplish we could maybe do it all in shell



/usr/bin/osascript <<AppleScript
tell application "System Events"
keystroke "$admin1_short"
keystroke return
delay 3.0
keystroke "$admin1_passwd"
delay 3.0
keystroke tab
keystroke return
end tell
AppleScript



It is basically calling variables for user name and password that are
hard coded in my shell script.


Yes input is what I meant, output can be tricky. :)


+1



l337 5cr!p70r



:)
--
Jared F. Nichols
Desktop Engineer, Client Services
Information Services Department
MIT Lincoln Laboratory
244 Wood Street
Lexington, Massachusetts 02420
781.981.5436


Geez Jared, don't encourage him!


Reply