1

I have a shell script that is using echo to give a continuous output (the progress of an rsync) that I am using AppleScript to run with administrator privileges. Before I was using NSTask to run the shell script, but I couldn't find a way to run it with the privileges that it needed, so now I am using applescript to run it. When it was running via NSTask, I could use an output pipe and waitForDataInbackgroundAndNotify to get the continuous output and put it into a text field, but now that I am using AppleScript, I cannot seem to find a way to accomplish this. The shell script is still using echo, but it seems to get lost in the AppleScript "wrapper." How do I make sure that the AppleScript sees the output from the shell script and passes it on to the application? Remember, this isn't one single output, but continuous output.

Sam W
  • 599
  • 2
  • 16
  • I bet it's impossible with standard AppleScript –  Aug 01 '14 at 21:58
  • That is the conclusion I've come to as well. I'm now trying to use Authorization Services to run the script via NSTask. I'm having some trouble with it though, if you or anyone else could help the post is at http://stackoverflow.com/questions/25086160/using-authorization-services-with-nstask Thanks! – Sam W Aug 01 '14 at 22:08

1 Answers1

1

Zero is correct. When you use do shell script, you can consider it similar to using backticks in perl. The command will be executed, and the everything sent to STDOUT will be returned as the result.

The only work around would be to have the your command write the output to a temporary file and then use do shell script "foo" without waiting. From there, you can read from the file sequentially using native AppleScript commands. It's clunky, but it'll work in a pinch.

user0721090601
  • 5,276
  • 24
  • 41
  • 1
    In the end I just ended up using a normal NSTask to do any scripts and we are just telling the ITS people to run it while booted from our "utility" external drive which boots as root. – Sam W Aug 08 '14 at 14:47