Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator Results Display Question

Hello everyone,

I'm hoping someone here might be able to help me out. I've spent the last 2 hours searching the web for an answer but have not been able to find anything - so any help is much appreciated!

I have created a shell script (based on info i've found on the net) within automator that looks like the following:

----
#!/bin/sh
SERVICE='<Program Name>'

if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
echo "$SERVICE is running, shutting it down..."
osascript -e "tell application \"<Program Name>\" to quit"
sleep 30
else
echo "$SERVICE is not currently running - Starting <Program Name>!"
open -a "<Program Name>.app"
fi
-----

Effectively, it will launch said application if it is not running, or inversely will shut it down if it finds that it is running. That works all fine and dandy (and I eventually intend to use it on a remote machine to stop and start an app). But my problem lies in knowing if it successfully worked...

You see, when the workflow is saved as an application and executed I can confirm it is working (I see the application closing/launching in the dock), but I really would like to have a dialog box appear showing me the results of running the command, since I will be eventually executing this on another mac remotely.

I heard it is possible to take the results of a given action in workflow and pass it to an applescript (which as a result will display an alert dialog box with that info that was passed on to it). What would be the code to accomplish this? Also, all I need to see is an "OK" button to close the window after i've seen the results.

Hopefully this makes sense... Let me know if you need any more info.

Posted on Nov 12, 2009 7:43 AM

Reply
Question marked as Best reply

Posted on Nov 12, 2009 7:50 AM

add the following 'run apple script" action to your workflow after your "run shell script" action.
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run {input, parameters}
display dialog input as text
end run</pre>
it will show the dialog with the results of your echo commands from the shell script action.
4 replies
Question marked as Best reply

Nov 12, 2009 7:50 AM in response to Evan Williams

add the following 'run apple script" action to your workflow after your "run shell script" action.
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run {input, parameters}
display dialog input as text
end run</pre>
it will show the dialog with the results of your echo commands from the shell script action.

Nov 15, 2009 4:27 AM in response to V.K.

Hi,

I tried this solution for a bunch of automator tasks I need to run, but I find that the text is truncated in the dialog box.

It seems that the AppleScript dialog box won't handle multiline output that is more than 3 lines, as the following code, run from Automator truncates the output to just under 4 lines (i.e. the very bottom of the 4th line is cut off.

on run {input, parameters}      display dialog "Line1\nLine2\nLine3\nLine4\nLine5\nLine6" end run


Is there a workaround for this?

Nov 15, 2009 6:57 AM in response to m0thr4

m0thr4 wrote:
Hi,

I tried this solution for a bunch of automator tasks I need to run, but I find that the text is truncated in the dialog box.

It seems that the AppleScript dialog box won't handle multiline output that is more than 3 lines, as the following code, run from Automator truncates the output to just under 4 lines (i.e. the very bottom of the 4th line is cut off.

on run {input, parameters}          display dialog "Line1 Line2 Line3 Line4 Line5 Line6" end run


Is there a workaround for this?

There probably is. you can try some modification of the following

on run {input, parameters}
display dialog paragraphs of input as text
end run


I suggest you ask on the AppleScript forum. there may be a better solution.

Automator Results Display Question

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.