How do you run cmd in Terminal using Eggplant?

I thought shell() command was the one that was suppose to do this, but it doesn’t work for me.

I tried to this shell(“convert ‘/Users/admin/Documents/1.tiff’ -scale ‘640x480’ ‘/Users/admin/Documents/1.jpg’”)

I have to run “convert ‘1.tiff’ -scale ‘640x480’ ‘1.jpg’” command in the “~/Documents/” folder of the Terminal.

Is there a way to do this?

Thanks!

I was able to solve it by doing this AppleScript command

do AppleScript {{
tell application “Terminal”
set foo to do script “cd Documents\rconvert ‘1.tiff’ -scale ‘640x480’ ‘1.jpg’”
end tell
}}

The problem that I have now is that this command opens up a new Terminal window every time this command runs…

How can you do this by just using shell() command or close Terminal after running this AppleScript?

Yikes! You certainly shouldn’t have to resort to calling AppleScript to make this work. If the issue is that the convert command needs you to ‘cd’ to the correct directory first, you might try using a ‘;’ to separate the commands like this:

shell "cd /Users/admin/Documents; convert '1.tiff' -scale '640x480' '1.jpg'"

If that doesn’t work you could try using the open process, write to process and close process commands, something like this:

open process "#1"
write "cd /Users/admin/Documents" & return to process "#1"
write "convert '1.tiff' -scale '640x480' '1.jpg'" & return to process "#1"
close process "#1"

But the shell command is simpler unless you’re doing a lot of similar processing, so hopefully it will work for you.

Thanks for replying, but both of the solutions don’t seem to work for me. I can only get it to work with the AppleScript method. And even that, I don’t think it will work for me because it doesn’t take any SenseTalk variables…

Is it possible to mix AppleScript part with SenseTalk like this?

put “path” into msg

do AppleScript {{
tell application “Terminal”
set foo to do script msg
end tell
}}

It doesn’t recognize the msg variable in the do AppleScript… Please help (

OK, I think I solved it by doing “do AppleScript merge of”.

put “something” into msg

do AppleScript merge of {{
tell application “Terminal”
set a to “[[msg]]”
do script a
end tell
}}

Please let me know if there are any easier ways of doing this…

I have no idea why shell or open process not working for me.

Yes, using the merge function is the suggested way to pass values from SenseTalk to AppleScript.

I would still like to know why shell (and open process) aren’t working for you. Is this the ImageMagick ‘convert’ command that you’re trying to call? If I can find a few minutes, I’ll try replicating that here. Meanwhile I wonder if you could try some simple variations on the command, like this:

shell "cd /Users/admin/Documents; convert 1.tiff 1.jpg"

or something even simpler like:

put shell("cd /Users/admin/Documents; ls")

That certainly works for me (so I expect it should work for you). By starting with something that works, perhaps we can discover what the cause of the problem is.

Yes, I am trying to use ImageMagick. The first shell command you posted runs without any failure, but it doesn’t do anything. Second shell command works fine, it displays all the contents in my Documents folder.

I wonder if it’s not finding the convert command. Try giving the full path to that command (e.g. /usr/local/bin/convert or wherever it is) and see if that works.

Yes, I think that’s the problem. We were able to solve this issue and run it with the shell command by exporting the path every time.

Thanks!