Compare commits

...

4 commits

Author SHA1 Message Date
Siegfried Krug 9792e0b701 adding example sh script 2016-10-02 20:42:13 +02:00
Siegfried Krug 30c780a1d3 Update README.md 2016-10-02 18:44:31 +02:00
Siegfried Krug c54bedbf60 Update README 2016-10-02 18:43:57 +02:00
Siegfried Krug ba80fc6691 experiments 2016-10-02 18:40:00 +02:00
4 changed files with 37 additions and 0 deletions

0
README
View file

2
README.md Normal file
View file

@ -0,0 +1,2 @@
# mPower Utils #
actually moving from sh to python

12
light_switch.py Executable file
View file

@ -0,0 +1,12 @@
#!/bin/python
host = "127.0.0.1"
user = "admin"
passwort = ""
#trying it with ssh
import subprocess
proc = subprocess.Popen(['ssh', 'user@host', 'echo 1 > /proc/power/output1'],
stdin=subprocess.PIPE)
if proc.retcode != 0:

23
toggle.sh Normal file
View file

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