Home AMX User Forum AMX Technical Discussion

Executing remote script over HTTP via Netlinx?

Is it possible to execute this line/script from a Nelinx master, directly? Any help highly appreciated! Thanks!
http://192.168.50.80:8080/cgi-bin/misc/misc.cgi?count=1264764330&func=restart_main_ok&SHUTDOWN=

Comments

  • viningvining Posts: 4,368
    Yes, just create a bit of code to open an IP socket and issue a get or post command. It's basically the same as examples on the forum for web scrapping for RSS weather, Weather.com, etc. the only difference is you don't want a return of data you're just issuing a command.

    You'll just need some code to call the function to do an IP_CLIEN_OPEN and in the online event call another function to send the request. If you go to the ModPedia section of the forum there are some modules posted that do this. RSSWeather, TiVO, Axis Cam, Digital Loggers, Ping URL etc, etc....
  • bobbob Posts: 296
    No problem on the IP_CLIENT_OPEN... connection should be TCP and the connection port the web servers 8080, right? Then SEND_COMMAND with GET and then the URL string, right? Thanks!
  • Joe HebertJoe Hebert Posts: 2,159
    bob wrote: »
    Then SEND_COMMAND with GET and then the URL string, right? Thanks!
    SEND_STRING
  • bobbob Posts: 296
    Joe, Vining, thanks much! Highly appreciated!
  • bobbob Posts: 296
    Don't really work, do I need to escape something within the quotes and do I need the $0D at the end? Or should I skip the http... part of the URL?

    SEND_STRING dvIPQnapServer, "'GET http://',sServer_Addr,':8080/cgi-bin/misc/misc.cgi?count=1264764330&func=restart_main_ok&SHUTDOWN=',$0D"

    I opened the connection with

    IP_CLIENT_OPEN(dvIPServer.PORT, sServer_Addr, 8080, IP_TCP) // IP_TCP = 1

    and it gets to the ONLINE event and also "ip status" shows the connection.
  • jweatherjweather Posts: 320
    You need to format the HTTP request correctly, in this case it will look something like

    "'GET /cgi-bin/misc/misc.cgi?count=1264764330&func=restart_main_ok&SHUTDOWN= HTTP/1.0',$0D,$0A,$0D,$0A"

    You can use any number of tools to sniff HTTP requests from your browser to see what they look like -- Live HTTP Headers for Firefox, Fiddler as a web proxy, or Wireshark.
Sign In or Register to comment.