[PLUG] Cron script help wanted
Roderick A. Anderson
raanders42 at gmail.com
Sat Mar 3 17:48:51 UTC 2012
Probably the quickest way would be to enclose $NEWIP and $OLDIP in
double quotes.
if [ "$NEWIP" != "$OLDIP" ]; then
OF course this will not fix the actual problem of why either of them are
empty.
As far as the URL. I get an error when I use the "http" version but get
through when I use "https". (That is after I accept the certificate.)
Rod
--
Rich Shepard wrote:
> This morning I'm seeing this error when the script looks at
> www.whatismyip.com for the assigned IP address:
>
> /home/rshepard/shell-scripts/ngetip.sh: line 4: [: too many arguments
>
> What is recommended for error checking and graceful recovery in a bash
> shell script like mine? BTW, I can point the browser to that URL and it does
> load so I don't know why the script is retuning this error.
>
> mgetip.sh:
>
> #!/bin/bash
> OLDIP=$(cat /home/rshepard/CURRENTIP)
> NEWIP=$(curl -s http://automation.whatismyip.com/n09230945.asp)
> if [ $NEWIP != $OLDIP ]; then # This is line 4
> echo $OLDIP
> echo $NEWIP
> echo $NEWIP > "/home/rshepard/CURRENTIP"
> echo $NEWIP >> "/home/rshepard/getiplog"
> <curl commands removed.>
> fi
>
> TIA,
>
> Rich
>
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
More information about the PLUG
mailing list