1

The below code is throwing a syntax error in AppleScript (when using Automator). Any suggestions what may be causing it as the code runs fine when running in Terminal?

on run {input, parameters}

    tell application "Terminal"

        activate (do script with command "perl -mURI -lne 'print ((URI->new(/([\S]+) \z/msx)->path_segments)[-1])' < testfile.txt > testfile1.txt")
    end tell

    return input
end run
2
  • What's your error? Try putting a return after "activate" Commented Jan 29, 2012 at 15:03
  • You don't need to tell the terminal to do anything. You only need: do shell script "put your code here" Commented Feb 17, 2017 at 23:10

1 Answer 1

2

I think you may need a line break after activate, i.e.

on run
    tell application "Terminal"
        activate
        do script "perl -mURI -lne 'print ((URI->new(/([\\S]+) \\z/msx)->path_segments)[-1])' < testfile.txt > testfile1.txt"
    end tell
end run

I've also taken out some redundant stuff and tested this on OS X 10.6.

Sign up to request clarification or add additional context in comments.

4 Comments

thanks for the response, the error I get is Expected “"” but found unknown token. any ideas?
See updated version above which works OK for me on OS X 10.6.
really strange.. still doesn't work for some reason.. keeps throwing the same error. Thanks anyway, will give this another look, if you have any other suggestions please let me know. thanks
OK - one other thing - you need to escape your backslashes - see further edited version above

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.