Search code examples
windowshttppostshortcut-file

HTTP POST from desktop shortcut?


I've got a wireless router with the Tomato custom firmware on it. There are a number of actions I'd like to perform from simple desktop shortcuts, such as turning off the wireless or running a command for checking the status of the FTP server on it.

I can do these from the 'system' tool which lets you execute shell commands and returns the output.

I have found from analysis of the markup on this page that this is done by way of a simple XMLHttp POST to shell.cgi, parameters action=execute&command=ls and the output is the STDOUT you'd get if you performed this on a local shell.

How can I create a desktop shortcut to perform these posts and somehow echo the response?

What I have figured I could do so far is to make an HTML file which launches a POST using jQuery using some predefined function depending on URI segments, which I'd vary for each of the shortcut files.

However does anyone know a better way of doing this programatically under Windows?


Solution

  • Use wget, which has a windows port. http://gnuwin32.sourceforge.net/packages/wget.htm

    wget --post-data 'action=execute&command=ls' http://router/shell.cgi
    

    You can run the command from a batch file on your desktop.