Re: Escape URL characters for shell
Re: Escape URL characters for shell
- Subject: Re: Escape URL characters for shell
- From: Christopher Nebel <email@hidden>
- Date: Mon, 1 Mar 2004 11:18:01 -0800
On Mar 1, 2004, at 6:19 AM, Gnarlodious wrote:
Entity Walter Ian Kaye spoke thus:
What's the easiest way to escape URL's before assembling a shell
command?
"quoted form of" seems like a good idea but doesn't do a thing for
me. Is
there another trick?
Funny, it works fine for me...
Any particular URL it's failing on?
Example:
set aURL to
"http://www.allmusic.com/cg/
amg.dllp=amg&uid=UIDMISS70402281058012766&sql=Ape2m96ho3ep1"
quoted form of aURL
I'm sure I have seen this construct return an escaped URL, but not
done like
this.
I'm saying this:
do shell script "sed -e '/^<th/{N;s/\\(<th.*\\n<tr>\\)/\\1" & thisSong
& "
<tr>/;};P;D' " & filePathPOSIX
where variable thisSong may contain a URL, but a URL contains "/".
The "quoted form" property is designed to get a string past sh(1) as a
single argument. Getting it past a tool with its own quoting rules
like sed(1) is an entirely different matter. The simplest solution in
this case would be to use a different character as the pattern
delimiter, something that can't occur in a URL. sed doesn't really
care what you use; "/" is merely traditional. For example:
echo foo/bar | sed -e 's|/|X|'
--> fooXbar
Since "/" isn't the delimiter character, you don't have to escape it.
--Chris Nebel
AppleScript Engineering
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.