Help with shell script implementation...!

Question…

I have made an Applescript to auto start and kill an ASR stream but have one last snag…

It is calling shell script commands and I cannot get them to output correctly…can someone help?

I need the “asr” command to output to something (terminal, a file, anything at all) so I can see the status of the command. The applescript developers page describing calling shell scripts falls short here…maybe someone can help me out?

Here is the script…it works fine right now, just cannot see what ASR is doing…

--Created by: Jimmy Schrage
--08/10/06
--Sets up and kills a Multicast stream on OS X server 10.4.3 or later


--Start it up!
display dialog "Please click OK to start the ASR Multicast session" buttons {"OK"} default button "OK"

--Enter Administrator Username
set userName to ""
display dialog "Please enter your Administrator username:" default answer "admin"
set userName to (text returned of result) as string

--Enter Administrator Password
set adminPass to ""
display dialog "Please enter your Administrator password:" default answer ""
set adminPass to (text returned of result) as string

--Choose the .DMG file (MAKE SURE THERE ARE NO SPACES IN THE FILE PATH)

choose file
set dmgPath to (result) as text

set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set dmgPath to text items of dmgPath

set AppleScript's text item delimiters to {"/"}
set dmgPath to dmgPath as string
set AppleScript's text item delimiters to ASTID
set dmgPath to "/Volumes/" & dmgPath

--See what the string path returns...
--display dialog "This should have / not : " default answer dmgPath


--Start the ASR process using the COCmulticast plist for the ASR Stream specifications
--Be sure to change the PLIST location 
do shell script "asr -source " & dmgPath & " -server /Volumes/ServerHD/Applications/Utilities/Multicast/PreConfigPlists/COCmulticast.plist -interface en0 &> /Volumes/ServerHD/Users/admin/Desktop/asrlog 2>&1 & echo $!" user name userName password adminPass with administrator privileges
set pid to the result

display dialog "Please click OK to end the ASR Multicast session" buttons {"OK"} default button "OK"

--Kill the ASR process
do shell script "kill " & pid user name userName password adminPass with administrator privileges

I think there are two options for you to consider:

  1. set the do shell script to a variable in the AppleScript (AS). For instance:
set shell_Reply to do shell script XXXXXXXXXXXX
display dialog shell_Reply

That should return whatever the shell script does back the AS so you can get a look at it.

  1. use the >> method to re-direct stdout to a file somewhere on your system:
do shell script XXXXXXXXXXXXXXXXXX >> /Users/YOURUSERNAME/Desktop/ShellReply.txt

Using the double ‘greater than’ signs will append to that file instead of re-writing, and you can have almost a log of every time the do shell script is executed.

Hope this helps, good luck.

I was trying the >> to append the log file…it didnt seem to work for me though…

Also the command I am doing (asr) is actually a command that continues to excecute (provides a data stream) until you kill it. What I need is a log with all the output from the asr command.

I think the problem is that the shell script is being pushed to the background and is spitting the output somewhere in the background instead of the log file I tell it too

-SF

EDIT:

I have tried all of these

do shell script “my_command & >output_file_path_and_name 2>&1 & echo $!”

do shell script “my_command >output_file_path_and_name & 2>&1 & echo $!”

do shell script “echo $! 1> output_file_path_and_name & my_command & >>&1 2>>&1 & echo $!”

If you run the command from the terminal does it provide ay feedback? I can’t recall every seeing a asr log anywhere, but I never really looked either. According to the main page it doesn’t seem to return and stdout unless it errors… perhaps you might want to try redirecting to a file “>>”, but also give it the “–verbose” option to generate some logs.

Yeah it echos the Prefrences you set automatically as well as tells you when it is looping (starting stream + time). I cant see that right now. The asrlog file is just something I wanted to spit that info into.

I will check out the --verbose stuff and see what happens

Thanks for all the help so far guys!!! :cool:

-SF