Posted on 10-06-2015 10:59 AM
Does anyone know if it is possible to pass the default script parameters and/or the custom parameters to an applescript?
It's easy enough to pass to a shell script, but I can't quite seem to figure out any syntax that will use the script parameters in an applescript.
If you've managed to do this could you give a quick sample of the syntax you used to utilize the parameter as a variable?
Solved! Go to Solution.
Posted on 10-06-2015 11:30 AM
@jasonaswell @bentoms This takes parameter 4 ($4 in bash) if it was passed and prompts for the value if it wasn't. Useful for things like Self Service scripts that you would also like to make usable with Casper Remote.
on run argv
if (count of argv) > 3 then
set result to item 4 of argv
else
set result to text returned of (display dialog "Enter the Username to be made an admin:" default answer "")
end if
....
end run
Posted on 10-06-2015 11:01 AM
A pure Applescript? As in a .scpt file? Or do you mean in a shell script that uses Applescript/osascript within it?
Posted on 10-06-2015 11:06 AM
@mscottblake we were talking about this in the AppleScript channel on the MacAdmins.org Slack.
What was the outcome again?
Posted on 10-06-2015 11:11 AM
@mm2270 pure Applescript
I can get it to work if I do a shell script with an osascript call inside of it, but I'm currently writing something in Applescript that's too long to reasonably be nested within a shell script.
Posted on 10-06-2015 11:30 AM
@jasonaswell @bentoms This takes parameter 4 ($4 in bash) if it was passed and prompts for the value if it wasn't. Useful for things like Self Service scripts that you would also like to make usable with Casper Remote.
on run argv
if (count of argv) > 3 then
set result to item 4 of argv
else
set result to text returned of (display dialog "Enter the Username to be made an admin:" default answer "")
end if
....
end run
Posted on 10-06-2015 11:36 AM
BEAUTIFUL!
Thanks @mscottblake!
Posted on 10-06-2015 12:01 PM
@mscottblake to the rescue!!
Posted on 10-06-2015 12:02 PM
That's good information. Bookmarking this page :)
Posted on 03-20-2018 07:28 AM
http://hints.macworld.com/article.php?story=2004012913110734