This discussion is archived
2487 Views 2 Replies Latest reply: Jun 18, 2010 12:02 AM by taylor.henderson
Currently Being ModeratedJun 17, 2010 11:59 PM (in response to taylor.henderson)This is a common issue.
Both the shell and AppleScript use the backslash to escape characters - in the shell's case it tells the shell to pass the next character as-is.
The issue you're running into is that AppleScript is jumping in and seeing the slash, which it also interprets as 'pass the next character as-is', so it strips the slash and passes the ampersand to the shell which, of course, treats it as it normally would since it is no longer escaped.
The solution is simple, though - double-escape the ampersand. The first slash will be interpreted by AppleScript to tell it to pass the next character (the second slash) to the shell. The shell then sees a single backslash which it interprets as an escape of the ampersand. Voila!
do shell script "open -a Firefox http://www.aSite.org/data.php?email=myName88%40live.com&#92;&#92;&passwd =myPass"
(Note that if Firefox is your default web browser you can just use the simpler form:
open location "http://www.aSite.org/data.php?email=myName88%40live.com&passwd=myPass"
which avoids the whole escaping issue altogether.)
Message was edited by: CamelotMac OS X (10.6.3)
Thank you. I had attempted that solution before, but because it was applescript giving me the error and not the shell I quickly dismissed it when it didn't work. Looking back on my code now I see I only ever tried to double escape with forward slashes by mistake :S
Thanks again though.applebook, Mac OS X (10.5.8), the white one