I have a shell script named “test” which executes a UNIX executable, which accepts command line arguments. I need to call the shell script “test” in an Applescript. I did try using do shell script command. Here is a snippet
do shell script "/Users/overflow/Desktop/test"
But the problem is, the UNIX executable is not getting executed. If i run the shell script as a stand alone it works fine.
Any help is much appreciated.
do shell script "cd /directory/of/script; ./your_script"
The command is:
do shell script "/Users/overflow/Desktop/./test"
Without seeing what your “test” shell script looks like, it is hard to tell what is happening.
You should read TN2065 for general advice about using do shell script.
One reason might be that your script is not using the full pathname of your “UNIX executable” to run it (i.e. your normal login environment has a modified PATH that lets the script work without using the full pathname of the binary, but the environment from do shell script does not have the same PATH element”this is described in TN2065).
In general, I would also try capturing stderr to see if it contains anything useful: do shell script “exec 2>&1 && .”. Usually do shell script discard stderr unless the exit code of the shell is non-zero (which is usually only the case if the last command itself exits with a non-zero edit code). When do shell script gets a non-zero exit code from the shell, it throws an error with a message that contains the output originally sent to stderr.
Beyond that, you could insert debugging statements into your script (“echo arrived at point 1”, “echo arrived at point 2”, “echo about to do something dubious”, etc.) to inspect the script’s progress.