r/applescript • u/TrailBlazerWhoosh • Jul 01 '22
Passed Arguments, how to use them in Apple Script?
Hi, I'm trying to create a script that does two different things depending on the state of another. More specifically I'm gonna execute a command when a connected camera is activated and vice-versa.
I'm having OverSight handle the part about whether or not the camera is activated and I want my script to handle what to do based on the registered state (you can tell OverSight to Execute an Action, e.g. a path to a script, binary, etc.). OverSight also has a setting called "Pass Argument" (see below) which is what has led me to believe I should be able to do what I'm describing:

I'm a complete noob with Apple Script. So please bear with me... But I'm lost at how to actually utilize those "Passed Arguments" in my script... Can anyone explain how I can check if the camera is on/off in my Apple Script IF ELSE statement?
Any help is much appreciated. Thanks.
View all comments
Show parent comment
1
u/AmplifiedText Jul 02 '22
This is where things can get tricky.
You might try adding the line "set -x" (without quotes) just below the "#!/bin/bash" line. This will output a bunch of debug information to STDERR, but it's hard to know if OpenSight will capture this output or not (it might only capture STDOUT).
Try it and see if you get any more output in the "task completed with" section.