Shell script anomaly?

Anyone know why this script works when executed in the Terminal, but doesn’t when it’s done within an applescript? I receive a runtime error “The command exited with a non-zero status.”

Format in the Terminal, it looks like this:
curl -s http://checkip.dyndns.org | awk ‘{print $6}’ | awk ’ BEGIN {FS = “<”} {print $1}’

Format within an applescript, it looks like this:

set publicIP to (do shell script "curl -s http://checkip.dyndns.org | awk '{print $6}' | awk ' BEGIN {FS = " < "} {print $1}'")

I thought it was an escape character issue at first at “<” so I tried it like "<" but it didn’t work either.

Model: MacBook Pro 2.66GHz Intel Core 2 Duo
AppleScript: 2.1.2
Browser: Safari 533.17.8
Operating System: Mac OS X (10.6)

Hi,

the double quotes must be escaped and the space characters in between must be removed


set publicIP to (do shell script "curl -s http://checkip.dyndns.org | awk '{print $6}' | awk ' BEGIN {FS = \"<\"} {print $1}'")

simpler solution


set publicIP to do shell script "curl http://whatismyip.org"

Thanks, Stefan, the simpler one worked like a charm. And just an FYI, escaping & removing the spaces on the other didn’t work. I had already tried that.

the shell script using dyndns works perfectly on my machine

Same here.

I must have mis-typed somewhere because when I open the script from here right into Script Editor, it works fine. So, my bad. Thanks again Stefan.