http missing when passing string from AS to shell script

NOTE: the bbcode of this site is surrounding the urls in my AS code below with the {URL} and {/URL} brackets…those should not be there. The code looks fine except for those.

this is a weird one. but, perhaps just due to my inexperience

My script is much more advanced than what I’m posting below. But, I’ve simplified it to replicate the issue. But, all I’m doing is creating a variable in AS and passing it to the shell to do some AWK stuff. But, I’ve found the string isn’t making it out of AS in tact.

The only difference between the following two snippets is I return the variable in AS in the first one. This returns the properly formatted URL with ‘http’ at the beginning.


set theString to "Frank%20Palmer%0James%20Hamilton"

set theURL to "http://www.mywebsite.net/search=" & theString

return theURL

do shell script "theAddress=$" & theURL & "
echo 'the URL  is' $theAddress"

In this second bit, I’ve only removed the return line so that shell echos back the variable. And, the ‘http’ is stripped off.
I’m scratching my head. I don’t know what is wrong here. Any suggestions?


set theString to "Frank%20Palmer%0James%20Hamilton"

set theURL to "http://www.mywebsite.net/search=" & theString

do shell script "theAddress=$" & theURL & "
echo 'the URL  is' $theAddress"

Sorry about the BBCode problem. Ray does know about it and is talking to his site developer. One way round the problem is to break up URL strings in posted scripts so that the site softward doesn’t recognise them as URLs.

The cure for the missing “http” is to use the quoted form of the URL text in the shell script:


set theString to "Frank%20Palmer%0James%20Hamilton"

set theURL to "http" & "://www.mywebsite.net/search=" & theString -- URL split to fool MacScripter's BBS software.

do shell script "theAddress=$" & quoted form of theURL & "
echo 'the URL  is' $theAddress"

Or:


set theString to "Frank%20Palmer%0James%20Hamilton"

set theURL to "http" & "://www.mywebsite.net/search=" & theString

do shell script "theAddress=$" & quoted form of theURL & "
echo \"the URL is $theAddress\"" -- echo string in double quotes.

thanks. that did the trick.