I need to release my IP address at the router on an hourly basis. The router page needs simple authentication and a button click to do the process. These are the HTTP calls:

Authenticate

GET /RST_st_dhcp.htm HTTP/1.1
Host: 10.10.1.1
Authorization: Basic YWRtaW46cGFzc3dvcmQ=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

Release button click

POST /st_dhcp.cgi?id=1044071018 HTTP/1.1
Host: 10.10.1.1
Content-Length: 31
Cache-Control: max-age=0
Authorization: Basic YWRtaW46cGFzc3dvcmQ=
Origin: http://10.10.1.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://10.10.1.1/RST_st_dhcp.htm
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

connect=Release&refreshScrn=yes

How can this be automated in OSX? Is it possible to write automator scripts for this?

link|improve this question

76% accept rate
Since Automator scripts don't start without user action, it wouldn't work using (only) Automator. – Daniel Beck Jan 1 at 13:55
feedback

1 Answer

I think curl and cron would get the job done. Something like this should work:

curl -u USERNAME:PASSWORD -d 'connect=Release&refreshScrn=yes' 'http://10.10.1.1/st_dhcp.cgi?id=1044071018'

You can tweak this command to add headers/attributes that your router demands, then put this into a cron job (crontab -e), with this cron definition:

0 * * * * $COMMAND 

where $COMMAND is the curl command above.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.