Need advanced shell scripting help
Hey all, I'm about to finish a really awesome shell script (not Maemo-related, but still very handy) but one last thing is holding it up. I need to run wget '$url' where the content of the $url variable is actually substituted, but the single quotes prevent that. So the command should be run like:
Code:
wget 'http://site.com/whatever.html'So what escape sequence can I use to make the contents of my variable come out between single quotes? Give me a working answer and I can share my handy script! :D |
Re: Need advanced shell scripting help
Eh... Just a man entry...
Quote:
|
Re: Need advanced shell scripting help
result=`wget \'${url}\'`
echo ${result} :confused: |
Re: Need advanced shell scripting help
Quote:
|
Re: Need advanced shell scripting help
Quote:
I assume the URL in question contains "interesting" characters which cause some breakage when used with double quotes on the command line. Have you tried using wget -i instead? |
Re: Need advanced shell scripting help
Quote:
http://www.planetmike.com/2005/04/12/wget-and-urls-with-ampersands/ I'll give wget -i a try, but putting the URLs in a file would be highly impractical...this script iterates through a list of URLs using cut. |
Re: Need advanced shell scripting help
Quote:
Anyway something like: Code:
URL="http://www.example.com/some web page.php?a=1&b=2&c=3" |
Re: Need advanced shell scripting help
I fixed the URL and I'm now working on the script...
|
Re: Need advanced shell scripting help
Quote:
Code:
$ wget -nv "http://talk.maemo.org/attachment.php?attachmentid=16109&d=1291329691"Quote:
Code:
$ long-pipeline-using-cut | wget -i - |
Re: Need advanced shell scripting help
WOOHOO Success! I had one other problem but wget "${URL}" did the trick! :D
Stand by for sweet script! :cool: |
Re: Need advanced shell scripting help
Alright so here is my script! It fetches emails from a Mailinator account.
Mailinator emails usually disappear after a while, but with this script you can run it hourly or whatever so you can make sure you get your emails.. Plus you can now use obfuscated mailinator addresses so nobody has to know the real name of the account you're checking. This would be very handy for, say, the contact email on a Tor server ;) Code:
#! /bin/shThanks for the help everyone! |
Re: Need advanced shell scripting help
Aha, I didn't know about mailinator. Looks useful, thanks!
There's something about unnecessary forks, temp files and long pipelines that bugs me, so here's a shorter version :-) Code:
#!/bin/sh |
Re: Need advanced shell scripting help
Quote:
Edit: Well I sat down and looked through it for a while and I finally understand how you did that...mostly :) |
| All times are GMT. The time now is 20:23. |
vBulletin® Version 3.8.8