Monday, January 2, 2017

Command Line Programming Never Grows Old

I use an IP power switch to energize my radios and tuner. This particular power switch uses cURL to communicate through a browser interface.  For example the following cURL command lines power on the equipment plugged into ports 1 and 2.

C:\curl\curl.exe "$1/nagios_powerctrl.csp?slave_id=1&port=1&ctrl_kind=1" -u $2:$3
C:\curl\curl.exe "$1/nagios_powerctrl.csp?slave_id=1&port=2&ctrl_kind=1" -u $2:$3

where

$1 is the URL of the power switch
$2 is the power switch login user name
$3 is the power switch password

If you put these two commands in batch file and then run the batch file, the equipment will be successfully energized. However, you will see the batch file open a window and run. Functional but not so elegant.

A simple solution is to create a shortcut pointing to the batch file and set the shortcut to run minimized. The shortcut runs the batch file while minimized, opening no desktop window.  The equipment is simply energized upon clicking on the shortcut.  A corresponding batch file turns the equipment off by changing the "kind=1" to kind=2".


No comments: