• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

Curl command for script

Scheduled Pinned Locked Moved webGUI
4 Posts 3 Posters 5.8k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T
    t0m5k1
    last edited by Mar 21, 2013, 3:09 PM

    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 3g

    I 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 :)

    pfsense 2.1-release, LinITX fx5402a = AMD Geode LX-800, 512Mb DDR ram, 4x 10/10 (RTL8100C), WDC WD1600BEVT-60ZCT1 13.01A13 (Capacity: 156.35 GB), WAN = USB E367 Huawei 3g dongle

    1 Reply Last reply Reply Quote 0
    • J
      jimp Rebel Alliance Developer Netgate
      last edited by Mar 27, 2013, 7:16 PM

      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

      Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

      Need help fast? Netgate Global Support!

      Do not Chat/PM for help!

      1 Reply Last reply Reply Quote 0
      • T
        t0m5k1
        last edited by Apr 15, 2013, 1:01 PM

        @jimp:

        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.

        pfsense 2.1-release, LinITX fx5402a = AMD Geode LX-800, 512Mb DDR ram, 4x 10/10 (RTL8100C), WDC WD1600BEVT-60ZCT1 13.01A13 (Capacity: 156.35 GB), WAN = USB E367 Huawei 3g dongle

        1 Reply Last reply Reply Quote 0
        • C
          charlie0440
          last edited by Apr 26, 2013, 5:50 AM

          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 :)

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
            This community forum collects and processes your personal information.
            consent.not_received