Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

midwich

macrumors member
Original poster
Jun 12, 2007
35
2
Hi there,
I've been drive quite mad trying to work out the correct syntax for activating a shell script in Applescript to start Vuze in headless mode and would appreciate any advice.

If I just paste the following into Terminal, it works fine:

java -XstartOnFirstThread -Dazureus.install.path="/Applications/Vuze.app/" -Dazureus.config.path="$HOME/Library/Application Support/Vuze/" -Duser.dir="/Applications/" -Dazureus.console.multiuser=1 -jar /Applications/Vuze.app/Contents/Resources/Java/Azureus2.jar --ui=console

[taken from boonlen's post of Sept 5 2009]



BUT if I try the following equivalent in Applescript, it doesn't:

set install_path to "Macintosh_HD/Applications/Vuze.app/"
set config_path to "Macintosh_HD/Users/gavin/Library/Application Support/Vuze/"
set user_dir to "Macintosh_HD/Applications/"
set azureus_jar to "/Macintosh_HDApplications/Vuze.app/Contents/Resources/Java/Azureus2.jar"

do shell script "java -XstartOnFirstThread -Dazureus.install.path= " & install_path & " -Dazureus.config.path= " & config_path & " -Duser.dir= " & user_dir & " -Dazureus.console.multiuser=1 -jar " & azureus_jar --ui=console"



I get this error message when I try to run the applescript:

Exception in thread "main" java.lang.NoClassDefFoundError: Macintosh_HD/Applications/Vuze/app/

Any ideas?


PS the reason I want to start Vuze this way is to be able to script the removal of completed torrents.
 
Well, there's a typos in this line,
Code:
set azureus_jar to "/Macintosh_HDApplications/Vuze.app/Contents/Resources/Java/Azureus2.jar"
Missing the / in front of Applications. Also, you don't need the Macintosh_HD bit at all, just do /Applications/...

You'll likely need to use the "quoted form of" syntax on your paths when putting them together so things are escaped appropriately.
 
Well, there's a typos in this line,
Code:
set azureus_jar to "/Macintosh_HDApplications/Vuze.app/Contents/Resources/Java/Azureus2.jar"
Missing the / in front of Applications. Also, you don't need the Macintosh_HD bit at all, just do /Applications/...

You'll likely need to use the "quoted form of" syntax on your paths when putting them together so things are escaped appropriately.


Thanks very much for such a fast response! I've changed the script to read:

set install_path to "Macintosh_HD/Applications/Vuze.app/"
set config_path to "Macintosh_HD/Users/gavin/Library/Application Support/Vuze/"
set user_dir to "Macintosh_HD/Applications/"
set azureus_jar to "/Macintosh_HD/Applications/Vuze.app/Contents/Resources/Java/Azureus2.jar"


do shell script "java -XstartOnFirstThread -Dazureus.install.path= " & quoted form of install_path & " -Dazureus.config.path= " & quoted form of config_path & " -Duser.dir= " & quoted form of user_dir & " -Dazureus.console.multiuser=1 -jar " & quoted form of azureus_jar --ui=console"



It complies fine, but unfortunately I get the same error when I try to run it.

PS have got rid of Macintosh_HD references too.
 
Try assigning the do shell script contents to a variable first and do a display dialog on it to see the exact string it is trying to execute.

Code:
set _script to "java -XstartOnFirstThread -Dazureus.install.path= " & quoted form of install_path & " -Dazureus.config.path= " & quoted form of config_path & " -Duser.dir= " & quoted form of user_dir & " -Dazureus.console.multiuser=1 -jar " & quoted form of azureus_jar --ui=console"
display dialog _script
 
AppleScript typically requires POSIX file paths, though you can convert it on the fly. Might be easiest just to change your path to use : instead of /. Thus,

Code:
set install_path to "Macintosh_HD:Applications:Vuze.app"

and so on. I'd leave the Macintosh_HD part there. BTW, is your drive actually named Macintosh_HD or is it Macintosh HD, because that's significant. I ask because the default is Macintosh HD, without the underscore, but obviously you may have changed it yourself.

jW
 
AppleScript typically requires POSIX file paths, though you can convert it on the fly.

That's true if the file paths are being used for say Finder, but he's passing them to Terminal, which needs slashes.
 
Try assigning the do shell script contents to a variable first and do a display dialog on it to see the exact string it is trying to execute.

Code:
set _script to "java -XstartOnFirstThread -Dazureus.install.path= " & quoted form of install_path & " -Dazureus.config.path= " & quoted form of config_path & " -Duser.dir= " & quoted form of user_dir & " -Dazureus.console.multiuser=1 -jar " & quoted form of azureus_jar --ui=console"
display dialog _script

Thanks very much for this, this is the result returned:

display dialog "java -XstartOnFirstThread -Dazureus.install.path= '/Applications/Vuze.app/' -Dazureus.config.path= '/Users/gavin/Library/Application Support/Vuze/' -Duser.dir= '/Applications/' -Dazureus.console.multiuser=1 -jar '/Applications/Vuze.app/Contents/Resources/Java/Azureus2.jar'"


Copied and pasted it into Terminal and definitely doesn't work. Differences between this output and the working version that I can see are that many of the double quotes are missing, and the ' --ui=console' bit originally at the end is also not there.
 
AppleScript typically requires POSIX file paths, though you can convert it on the fly. Might be easiest just to change your path to use : instead of /. Thus,

Code:
set install_path to "Macintosh_HD:Applications:Vuze.app"

and so on. I'd leave the Macintosh_HD part there. BTW, is your drive actually named Macintosh_HD or is it Macintosh HD, because that's significant. I ask because the default is Macintosh HD, without the underscore, but obviously you may have changed it yourself.

jW

Thanks for this, I changed the script to read:

set install_path to quoted form of the POSIX path of "Macintosh_HD:Applications:Vuze.app/"
set config_path to quoted form of the POSIX path of "Macintosh_HD:Users:gavin:Library:Application Support:Vuze:"
set user_dir to quoted form of the POSIX path of "Macintosh_HD:Applications/"
set azureus_jar to quoted form of the POSIX path of "Macintosh_HD:Applications:Vuze.app:Contents:Resources:Java:Azureus2.jar"

set _script to "java -XstartOnFirstThread -Dazureus.install.path= " & install_path & " -Dazureus.config.path= " & config_path & " -Duser.dir= " & user_dir & " -Dazureus.console.multiuser=1 -jar " & azureus_jar --ui=console"
display dialog _script


do shell script "java -XstartOnFirstThread -Dazureus.install.path= " & install_path & " -Dazureus.config.path= " & config_path & " -Duser.dir= " & user_dir & " -Dazureus.console.multiuser=1 -jar " & azureus_jar --ui=console"





The dialog output reads:

display dialog "java -XstartOnFirstThread -Dazureus.install.path= '/Applications/Vuze.app:' -Dazureus.config.path= '/Users/gavin/Library/Application Support/Vuze/' -Duser.dir= '/Applications:' -Dazureus.console.multiuser=1 -jar '/Applications/Vuze.app/Contents/Resources/Java/Azureus2.jar'"





I think that's the same as before, oh well! If I put the 'do shell script' line first, I get this output as previously:

Exception in thread "main" java.lang.NoClassDefFoundError: /Applications/Vuze/app:



Yes I changed the name of the HD some while ago to include the underscore as I tend to have enough trouble with scripts without dealing with spaces too! The occasional obscure app may also have trouble with the space I've found and not necessarily be clear that that's the problem, so better safe than sorry.
 
You had a quote imbalance, which caused the end to get cut out. Try this,

Code:
set install_path to "/Applications/Vuze.app/"
set config_path to "/Users/gavin/Library/Application Support/Vuze/"
set user_dir to "/Applications/"
set azureus_jar to "/Applications/Vuze.app/Contents/Resources/Java/Azureus2.jar --ui=console"

do shell script "java -XstartOnFirstThread -Dazureus.install.path=" & quoted form of install_path & " -Dazureus.config.path=" & quoted form of config_path & " -Duser.dir=" & quoted form of user_dir & " -Dazureus.console.multiuser=1 -jar " & azureus_jar
I can't test it as I don't have Vuze. I fixed the quotes and removed some potentially troublesome spaces.
 
You had a quote imbalance, which caused the end to get cut out. Try this,

Code:
set install_path to "/Applications/Vuze.app/"
set config_path to "/Users/gavin/Library/Application Support/Vuze/"
set user_dir to "/Applications/"
set azureus_jar to "/Applications/Vuze.app/Contents/Resources/Java/Azureus2.jar --ui=console"

do shell script "java -XstartOnFirstThread -Dazureus.install.path=" & quoted form of install_path & " -Dazureus.config.path=" & quoted form of config_path & " -Duser.dir=" & quoted form of user_dir & " -Dazureus.console.multiuser=1 -jar " & azureus_jar
I can't test it as I don't have Vuze. I fixed the quotes and removed some potentially troublesome spaces.

That works! Fantastic, thank you so much for being so patient I really appreciate it :) :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.