Mailinglist Archive: opensuse (1319 mails)

< Previous Next >
Re: [opensuse] Re: Dynamic DNS service - setting it up - scripting problem
On 2016-12-03 16:02, Yamaban wrote:
On Sat, 3 Dec 2016 15:29, Carlos E. R. <robin.listas@...> wrote:

Let's try "simple" first:

[code of cron-script]
# make sure LASTKNOWNIP is clean:
tempip=`echo $LASTKNOWNIP | tr -d '\r'`

You are right, the last IP was stored with the error.

# get actual info from router, log errors
/usr/local/bin/GetIpFromRouter.exp > /run/DDNS/router_output.log 2>

# grep out PPoE line, catch out wan ip, log errors
CURRENTIP=`grep PPPoE /run/DDNS/router_output.log | tr -d '\r' | awk
'{print $10}'` 2> /run/DDNS/router_output_greperr.log

echo "Last IP: '$LASTKNOWNIP' Current IP: '$CURRENTIP'"

that code (which is mostly what You'he shown) should give you:

Last IP: 'MY_IP' Current IP: 'MY_IP'

Ok, now what did I different:

1. Added cleanup of LASTKNOWNIP, most likely it still will have that
added '\r' or '^M', lets remove that.

Yes, it is so.

2. Removed dos2unix of the router_output_err.log, why the error log??

Just in case there is some error, know about it. The intention is to email
those to myself.
Thus if the script fails somehow while I'm out, I still get an email with info,
enough info to access via the IP and correct problem.
Hopefully! We all know how sure things fail in computing ;-)

3. Added cleanup to the output of grep, before awk.

How did I do that cleanup? Using the most simple tool available: "tr"

Right! I forgot about that tool.


Now I have a different unrelated problem: says I'm not authorized.
Why? It worked before. That's with wget. curl appears to works, but doesn't
really say:

cer@isengard:~> curl --anyauth -u USER:PASS
0000 Transaction successful, # affected row(s) = 0

The output is misleading, see wget:

cer@isengard:~> wget --user=LOGIN --password=PASSWORD
--2016-12-03 16:43:58--
Resolving (, 2a03:7520:4c68:2::e047
Connecting to (||:80... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Reusing existing connection to
HTTP request sent, awaiting response... 200 OK
Length: 51 [text/plain]
Saving to: ‘update?’

51 --.-K/s in 0s

2016-12-03 16:43:58 (4,29 MB/s) -
‘update?’ saved [51/51]


Dunno, there is a 401 Unauthorized, then a 200 OK. I don't know what happened.

The saved "file" from above wget says:

0000 Transaction successful, # affected row(s) = 0

Maybe that means success. :-?

I need nutrients and rest. O:-)

Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 "Bottle" at Telcontar)

< Previous Next >
Follow Ups