Curl command for script
-
Hey people,
I am trying to create a script to turn on/off my wan interface at certain times
I have the url's:
http://192.168.1.254/status_interfaces.php?action=Connect&if=wan http://192.168.1.254/status_interfaces.php?action=Disconnect&if=wan
however my curl skills are non existent :( but I need to provide my admin username & password & i have no clue how to do this.
What I am attempting to do here is to:
turn on my 3g after 23:00
check a work server for a change
if change present then rsync
if no change present disconnect from work
disconnect 3gI have to do this after 23:00 because at that time I know no one will be working & potentially this can be a large download upto 1 Gb & I do not wish to do this prior to 2300 as this will affect my daytime (yes I have 2 allowance's daytime: 0500-2300 & night time: 2300-0500) 3g bandwidth allowance which is used by my family also leaving the dongle connected is not an option as everyone leaves their pc's turned on & possibly webpages, IM clients, skype etc all running too, so if I leave it connected bandwidth is consumed for no reason which is not good for 3G!!!.
Thanks in advance for any advice :)
-
You'll need to "login" first and save cookies, as is done on the backup page:
http://doc.pfsense.org/index.php/Remote_Config_Backup
-
You'll need to "login" first and save cookies, as is done on the backup page:
http://doc.pfsense.org/index.php/Remote_Config_Backup
Thanks for the response. Yea kinda gathered I would need to login in some way but from previous experience using wget in scripts can cause problems hence why I mentioned CURL.
-
Here are the commands in curl (wish I found that wiki link a while back I had to work these out):
login (replace the url username & password:
curl -k -L -b cookies.txt -c cookies.txt –verbose -d "usernamefld=yourusernamehere&passwordfld=yourpasswordherer&login=Login" "https://192.168.1.1/index.php"
To do a post:
curl -k -L -b cookies.txt -c cookies.txt --verbose -d "action=Disconnect&if=wan" "https://192.168.1.1/status_interfaces.php"
NOTE: A lot of the pfsense pages use csrf. It this case you have to get the value from the page you are posting from and post that with the command. Luckily for you the status_interfaces page does not use them :)