Do Shell Script Problems

Hello,

I am having problems with a Do Shell Script command for the command line version of Compressor 2.

If you have Final Cut Studio (or Studio 2 now), you can see what Compression clusters are available to you by going to the Terminal typing like so:

AntonMacBookPro:~ anton$ cd /Applications/Compressor.app/Contents/MacOS/
AntonMacBookPro:/Applications/Compressor.app/Contents/MacOS anton$ ./Compressor -show
2007-05-19 22:21:25.159 Compressor[680] in ShowCluster for tcp://10.0.1.210:49167
2007-05-19 22:21:25.160 Compressor[680] in ShowCluster created URL
2007-05-19 22:21:25.160 Compressor[680] in ShowCluster created user client
2007-05-19 22:21:25.160 Compressor[680] in ShowCluster created got accesskey
2007-05-19 22:21:25.175 Compressor[680] in ShowCluster connected to user client
2007-05-19 22:21:25.181 Compressor[680]

So the Cluster name is “MacPro Cluster”.

Now, when I try to do this via a Do Shell Script command, it times out and causes my script to hang. My current work around is to Open Terminal and read it from there. But I hate it becuase my application looks nice and then pow…two terminal windows open up. Doesn’t look professional at all. This is just part of a larger script, but you get the idea.



tell application "Finder"
	set compressor_appfile to (application file id "com.apple.compressor.Compressor" as Unicode text)
end tell
set the compressor_UNIXfile to (compressor_appfile & ":Contents:MacOS:Compressor") as alias
set the UNIXfile_path to the quoted form of the POSIX path of the compressor_UNIXfile


tell application "Terminal"
	launch
	do script with command (UNIXfile_path & space & "-show")
	tell window 1
		set background color to "black"
		set cursor color to "green"
		set normal text color to "yellow"
		set bold text color to "red"
		set title displays shell path to true
		set title displays window size to true
		set title displays device name to true
		set title displays file name to true
		set title displays custom title to true
		set custom title to "bozo"
		set number of columns to 80
		set number of rows to 40
	end tell
	delay 2
	set this_data to the contents of window 1
end tell
delay 3

do shell script "killall Terminal"

set the cluster_names to {}
repeat with i from 1 to the count of paragraphs of this_data
	set this_paragraph to paragraph i of this_data
	if this_paragraph contains "<cluster name" then
		set x to the offset of "\"" in this_paragraph
		set y to text from (x + 1) to -1 of this_paragraph
		set x to the offset of "\"" in y
		set the cluster_name to text 1 thru (x - 1) of y
		set the end of the cluster_names to the cluster_name
	end if
end repeat

set the target_cluster to (choose from list cluster_names with prompt "Pick the cluster node:") as Unicode text
if the target_cluster is "false" then tell me to quit



Anyone have an idea to get around the do shell script command problem?

Cheers.

Hi,

try to avoid the timeout with

with timeout of 2 * hours seconds
	do shell script "xyz"
end timeout

Does that work? I never saw that before, but I’m still new so I don’t know… but why not this?

do shell script (UNIXfile_path & space & "-show")

and why (do shell script “killall Terminal”) instead of (tell application “Terminal” to quit)?

I think you can alter your Compressor -show command to include a timeout so it should be something like this:
Compressor -show -timeout 1 (1 being the the number of seconds you want before the command times out - the default is don’t time out).