Posted on 02-22-2011 12:24 AM
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
Posted on 02-22-2011 12:27 AM
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
Posted on 02-22-2011 12:33 AM
Correct, scripts should run in alphabetical order, and follow the priority.
Posted on 02-22-2011 12:41 AM
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
Posted on 02-22-2011 12:47 AM
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.
Posted on 02-22-2011 12:49 AM
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.
Posted on 02-22-2011 12:54 AM
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
Posted on 02-22-2011 12:56 AM
In, yes, out, no. But you can redirect output to a variable if you want...
Posted on 02-22-2011 12:57 AM
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.
Posted on 02-22-2011 01:04 PM
Yes input is what I meant, output can be tricky. :)
Posted on 02-22-2011 01:19 PM
+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
Posted on 02-22-2011 01:21 PM
Geez Jared, don't encourage him!