image
image
Ticket Options
Question Profile
DATEAug 22, 2006
TICKET#27834
STATUSClosed
SUBJECTif then statement in automator
CATComputers, Operating Systems, Applications or Connected Devices
TYPEOperating System Features, Bugs and Problems
DESCApple
DESC10.4.X (Tiger)
PLATFORMApple Macintosh (PowerPC G3,G4,G5)
MODELiBook G4
PROC1.25
RAM768
DRIVE30GB
NAMEDan
USERNAMEfrozendice
TECHNICALExpert
ISSUEStumped
Question Details
TICKET ARCHIVE -> if then statement in automator
frozendice - Aug 22, 2006 - 6:36 pm
image
image
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?
macbri - Aug 22, 2006 - 11:44 pm
image
image
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
frozendice - Aug 23, 2006 - 3:02 pm
image
image
Thanks for the help! For some reason I just didn't think of even using applescript.

IF THIS IS YOUR QUESTION AND YOU WISH TO RESPOND, LOGIN HERE FIRST.


Search Engine Friendly URLs by vBSEO 3.1.0