I am trying to write my own dynamic DNS client to check my router's external IP address and upload it somewhere where I can find it. Here's the simplified script scrapeip:
while read -r line
echo Trying to scrape IP from: $line
$line > scrapedip.txt
if [ $? -eq 0 ]; then
echo success # ...and do something useful
done < ipscrapers.txt
The script reads a file ipscrapers.txt, line by line, and tries to execute each line. If one succeeds it breaks the loop. For now I only have one line in ipscrapers.txt:
wget -qO- http://checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
When I run this script I get:
Trying to scrape IP from: wget -qO- http://checkip.dyndns.org
| sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
wget: Invalid --execute command ‘'s/.*Current’
When I run the wget line at the command line it works fine, also if I have it directly in the script it works. It does not work when I read the command line from a file. How can I fix this?
The point of all this is to eventually have a longer list of scrapees, and then rotate the list after every use round-robin style, spreading the load overs many servers.