First I run a shell script, then it outputs text. All I'm trying to do is compare the output of the script with a string. Eg. the output of my output says DOG, I want to check if it says DOG and then go on to the next task or die. Is this impossible for automator? One of the simplest programing things to do and automator can't do this?
Hi Dan -
Yup, that's right, Automator knows nothing about conditional statements and follows a purely rigid step-by-step set of actions (so far). Here's hoping it gets a boost in the future! In the meantime, here's one way , albeit a bit of a hack, to do what you want. Feed the output of your shell script to a "Run Applescript" action, the contents of which look like this:
Code:
on run {input, parameters}
if item 1 of input is not "DOG" then
error number -128
end if
return "Ok"
end run Of course instead of returning "Ok" you could return whatever you want to be used/manipulated by the following action. Note the "error number -128" applescript statement which will cause the workflow to die without an annoying dialog telling you it died...
And yes, this is still rudimentary if/then/else stuff, if you want more complex logic in your workflow I'd suggest moving away from Automator and writing your entire 'workflow' in Applescript. Apple have a nice article on launching shell scripts from AppleScript,
Tech Note #TN2065
Hope this helps
Thanks for the help! For some reason I just didn't think of even using applescript.