running a perl script from within applescript using do shell script???

I am trying to run a perl script from within applescript. The command works fine from a Terminal but generates an error within Applescript. It seems to be to do with applescript quoting some of the params when it passes them to the perl script. However, I’m new to perl and Applescript so I could be completely wrong. I would appreciate anyone who can help break out of my stupidity!

I am tearing my hair out trying to get this to work trying various combinations of escaped characters, different shells, different quotes (quoted form of, etc) but I can’t work out what the basic problem is.

Kind Regards,
Kefa.

APPLESCRIPT COMMAND (THAT DOESN’T WORK)

do shell script (“/Users/dan/Library/Scripts/flac2mp3/flac2mp3.pl ‘/Users/dan/Music/Squeezebox Music/Originals’ ‘/Users/dan/Music/iTunes/iTunes Music/Transcoded Music’”)

APPLESCRIPT ERROR MESSAGE (NOTE ALL THE ESCAPED CHARS)

“Processing directory: /Users/dan/Music/Squeezebox Music/Originals
5549 flac files found. Sorting…done.
Processing "bent/Later (Compiled & Mixed By Bent/01. Eastern Lights (Neon Heights Mix) .flac"
Processing "joni mitchell/hejira/09. refuge of the roads.flac"
flac --decode --stdout --silent "joni mitchell/hejira/09. refuge of the roads.flac"| lame --preset standard --replaygain-accurate --quiet - "/Users/dan/Music/iTunes/iTunes Music/Transcoded Music/joni mitchell/hejira/09. refuge of the roads.mp3" failed with exit code 32512”

TERMINAL COMMAND (WORKS FINE)

/Users/dan/Library/Scripts/flac2mp3/flac2mp3.pl ‘/Users/dan/Music/Squeezebox Music/Originals’ ‘/Users/dan/Music/iTunes/iTunes Music/Transcoded Music’

That’s just happening when the error message is returned to AppleScript.

Can you post the contents of the perl script?

Of course, it’s from Robin Bowes website (http://robinbowes.com/filemgmt/index.php).

It’s version v0.2.7 of flac2mp3 which can be downloaded from here: http://robinbowes.com/filemgmt/visit.php?lid=11

I hope you don’t mind if I don’t include it here as it’s quite lengthy!

Thanks Jacques. This does the trick nicely. :slight_smile:

Is this something to do with the fact that when you start a Terminal session it logs you on as a user (so you gets your default path), but when a session is started through Applescript it doesn’t do this?

Cool thing now is that I can set up some Folder Actions to automate this in the background whenever a new flac file is added. I haven’t quite worked out what the correct trigger is though.

Thanks again for your help - much appreciated.

Basically, yes.

See also: Technote 2065: do shell script

Hi,

I just wanted to say that I’ve had problems with my website - it got attacked by script kiddies. :frowning:

I should be back up now.

Please let me know if you have any problems.

R.