How to echo shell script in Automator

automatorcommand line

I have an Automator service which runs a shell script (ffmpeg command).
I'm looking for a way to see the output of the terminal while ffmpeg does it's thing.
Adding echo to the ffmpeg command doesn't work. I read this can be achieved using AppleScript but I wish to stay in bash if possible.
Further more, presenting a progress bar of the transcoding would be just awesome.
This is how my Automator action looks like:
enter image description here

Best Answer

To get your shell (bash) script to output to the screen continually so that you can see the progress, you need to launch it from AppleScript. Basically, this is a script that is launching another script. Use the script below to kick of the script that contains your ffmpeg command. You can even pass arguments to your script as you would normally.

For this example, I have a simple bash script that prints out the first command line argument.

#! /bin/bash
# test.sh
echo $1
exit

Next, is the AppleScript code that kicks off the bash script

tell application "Terminal"
   do script "<path>/test.sh 'Hello World'; exit"
   activate
end tell

Note, that if you have any strings with spaces that you need to pass, they MUST be enclosed in single quotes. Double quotes will cause an error in AppleScript.

When you run the script, it will open a Terminal window and anything that gets output will display on the screen.