From 9792e0b701dfcbc997e6a8b60bf4a9ef9dae6c0a Mon Sep 17 00:00:00 2001 From: Siegfried Krug Date: Sun, 2 Oct 2016 20:42:13 +0200 Subject: [PATCH] adding example sh script --- toggle.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 toggle.sh diff --git a/toggle.sh b/toggle.sh new file mode 100644 index 0000000..fb16518 --- /dev/null +++ b/toggle.sh @@ -0,0 +1,23 @@ +#!/bin/bash +export PATH=/opt/local/bin:/opt/local/sbin:$PATH +export MANPATH=/opt/local/share/man:$MANPATH +# +# test if mpower IP , port and output is passed to script +# +if [ $# -ne 3 ] # Test number of arguments to script. +then + echo "MpowerOnOff.sh - Parameters IP, port(1-8) or output(0|1) not specified as a parameter" + exit + fi + MpowerURL="$1" + MpowerPort="$2" + MpowerOutput="$3" + MpowerCmd="output="$MpowerOutput" -b ""AIROS_SESSIONID=01234567890123456789012345678901"" "$MpowerURL"/sensors/"$MpowerPort + #echo $MpowerURL + #echo $MpowerPort + #echo $MpowerOutput + #echo $MpowerCmd + #login + curl --silent -X POST -d "username=admin&password=marshall" -b "AIROS_SESSIONID=01234567890123456789012345678901" $MpowerURL"/login.cgi" + #toggle port + echo $(curl --silent -X PUT -d $MpowerCmd )