Simple terminal script not working

I am a real noob to applescript. This should be simple, but I can’t get it to work. I want to CD to my desktop and execute hdiutil to convert palm.cdr image to palm.iso. I plan to make this more generic, but can’t even get this to work:

tell application “Terminal”
activate
do script “cd ~/desktop”
do script “hdiutil makehybrid -iso -joliet -o Palm.iso Palm.cdr”
end tell

I get 3 terminal windows

  1. Opens a new terminal window at my home
  2. Executes cd and gets to desktop
  3. Executes hdiutil, but in my home folder not desktop.

Forgive me for such a stupid question.

Try leaving out the Terminal and use do shell script instead.
You separate commands with “;”


do shell script "cd ~/desktop; hdiutil makehybrid -iso -joliet -o Palm.iso Palm.cdr"

That worked great! Thank you. I am trying to learn something here. Can someone please explain what is wrong with my script?

You have to tell Terminal to execute the commands in the same window.


tell application "Terminal"
    activate
    do script "cd ~/desktop" in window 1
    do script "hdiutil makehybrid -iso -joliet -o Palm.iso Palm.cdr" in window 1
end tell

Btw, I don’t script Terminal so to find out how to do this I looked in it’s dictionary.


set theResult to do script unicode text ¬
     in tab | window | anything

Although looking in the dictionary is not always helpful it is a good place to start. :wink:

Cheers,

Craig

Craig,

Thank you for your response. I had gone to dictionary, but did not relate the windows option. I really appreciate your response because I am trying to learn this how to code applescript.

Just keep at it. I know it is hard at first but it does get easier. :smiley:

And use this site as a resource. There are a lot of questions already
answered in the archives and don’t forget to check out the tutorials.

Cheers,

Craig