[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Substitute bash code into a curl command
From: |
Greg Wooledge |
Subject: |
Re: [Help-bash] Substitute bash code into a curl command |
Date: |
Tue, 25 Aug 2015 12:30:23 -0400 |
User-agent: |
Mutt/1.4.2.3i |
On Tue, Aug 25, 2015 at 05:54:18PM +0200, Csányi Pál wrote:
> I want to set a cron job with the following command:
> curl http://[USERNAME]:address@hidden/update?hostname=[DOMAIN]&myip=[IP]
>
> So the command could be eg.
> curl -v
> http://username-gmail-com:address@hidden/update?hostname=somename.ipdns.hu&myip=95.85.***.***
Two things.
First, you MUST use quotes here, because the & is a metacharacter that
will cause the input line to be split into two commands.
curl -v
"http://$username:address@hidden/update?hostname=$hostname&myip=$new_ip_address"
> My question is: can one use this command as a cron job to execute
> every say 10 minutes but so so the current IP address of the eth0
Second, crontab is NOT the appropriate trigger for this. Your IP
address can change any time your DHCP server says so. You want the
dynamic-DNS notification to be done whenever the IP address changes,
not 10 minutes later.
This is slightly off topic for this list -- you really should be asking
on a list for your operating system. Since you said eth0, I will assume
some kind of Linux.
Linux's DHCP client daemon (at least, the one most commonly in use
these days) provides hooks to do this. See
http://mywiki.wooledge.org/IpAddress#My_Address.2C_It_Changes
Replace the dync command with your curl command, plug in the appropriate
values, and you should be set. At least if your DHCP client is like mine.