So I have a bash script like this:


gsed -i -E 's/something/somethingelse/' "$FILE"
echo "Modified File"

When I run this from command line, it echoes the last line, so no errors or something and makes changes to the file. I then try to create an Applescript with these contents:

set msg to do shell script "/path/to/script.sh"
display dialog msg

When I run it, it dutifully displays the dialog, but does not actually change the file some_file.js. How can this be possible?

Update: If I use sed -i "" -E 's/something/somethingelse/' "$FILE" instead, it works.

  • Where is gsed? Reading more I'll bet not on the path. Altering ~/.bash( files will not chnage this - I would use the full path to gsed – mmmmmm Feb 29 '16 at 21:19
  • @Mark Oh it's in the PATH alright. It's installed via macports. But setting the full path does help. I thought I would be alerted with an error message (as I have seen before) that the command was not found, but apparently the applescript just silently fails. – oarfish Feb 29 '16 at 21:40
  • Do you capture stderr? How did yeast the PATH? – mmmmmm Feb 29 '16 at 21:44
  • 1
    PATH als seen in Terminal may not be the same as PATH in Automator, so it's best to add the full path to non-standard commands. – nohillside Feb 29 '16 at 22:13