Projects/SpaceNotifier: Difference between revisions
< Projects
No edit summary |
mNo edit summary |
||
Line 7: | Line 7: | ||
}} | }} | ||
App for notifing of the space status | App for notifing of the space status | ||
== sshlogin.exp | |||
#!/usr/bin/expect -f | |||
# Expect script to supply root/admin password for remote ssh server | |||
# and execute command. | |||
# This script needs three argument to(s) connect to remote server: | |||
# password = Password of remote UNIX server, for root user. | |||
# ipaddr = IP Addreess of remote UNIX server, no hostname | |||
# scriptname = Path to remote script which will execute on remote server | |||
# For example: | |||
# ./sshlogin.exp password 192.168.1.11 who | |||
# ------------------------------------------------------------------------ | |||
# Copyright (c) 2004 nixCraft project <http://cyberciti.biz/fb/> | |||
# This script is licensed under GNU GPL version 2.0 or above | |||
# ------------------------------------------------------------------------- | |||
# This script is part of nixCraft shell script collection (NSSC) | |||
# Visit http://bash.cyberciti.biz/ for more information. | |||
# ---------------------------------------------------------------------- | |||
# set Variables | |||
set password [lrange $argv 0 0] | |||
set ipaddr [lrange $argv 1 1] | |||
set scriptname [lrange $argv 2 2] | |||
set arg1 [lrange $argv 3 3] | |||
set timeout -1 | |||
# now connect to remote UNIX box (ipaddr) with given script to execute | |||
spawn ssh admin@$ipaddr $scriptname $arg1 | |||
match_max 100000 | |||
# Look for passwod prompt | |||
expect "*?assword:*" | |||
# Send password aka $password | |||
send -- "$password\r" | |||
# send blank line (\r) to make sure we get back to gui | |||
send -- "\r" | |||
send -- "$scriptname $arg1\r" | |||
send -- "exit\r" | |||
expect eof | |||
== space_state.sh == | |||
#!/bin/bash | |||
USERS=`./sshlogin.exp <PASSWORD> 192.16 8.88.2 sh stations | grep -c Bitlair` | |||
STATE=`cat /tmp/spacestate 2>/dev/null` | |||
if [ $USERS -gt 0 ]; then | |||
if [ "$STATE" != "open" ]; then | |||
echo "WE MOETEN OPEN" | |||
echo "open" > /tmp/spacestate | |||
fi | |||
fi | |||
if [ $USERS -lt 1 ]; then | |||
if [ "$STATE" != "dicht" ]; then | |||
echo "WE MOETEN DICHT" | |||
echo "dicht" > /tmp/spacestate | |||
fi | |||
fi |
Revision as of 18:11, 15 May 2011
Project SpaceNotifier | |
---|---|
Name | SpaceNotifier |
Start | |
End | |
Contact | User:AK47 |
Website | http://hier |
Information | Space Notifier apje |
Status | Alpha |
App for notifing of the space status
== sshlogin.exp
#!/usr/bin/expect -f # Expect script to supply root/admin password for remote ssh server # and execute command. # This script needs three argument to(s) connect to remote server: # password = Password of remote UNIX server, for root user. # ipaddr = IP Addreess of remote UNIX server, no hostname # scriptname = Path to remote script which will execute on remote server # For example: # ./sshlogin.exp password 192.168.1.11 who # ------------------------------------------------------------------------ # Copyright (c) 2004 nixCraft project <http://cyberciti.biz/fb/> # This script is licensed under GNU GPL version 2.0 or above # ------------------------------------------------------------------------- # This script is part of nixCraft shell script collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information. # ---------------------------------------------------------------------- # set Variables set password [lrange $argv 0 0] set ipaddr [lrange $argv 1 1] set scriptname [lrange $argv 2 2] set arg1 [lrange $argv 3 3] set timeout -1 # now connect to remote UNIX box (ipaddr) with given script to execute spawn ssh admin@$ipaddr $scriptname $arg1 match_max 100000 # Look for passwod prompt expect "*?assword:*" # Send password aka $password send -- "$password\r" # send blank line (\r) to make sure we get back to gui send -- "\r" send -- "$scriptname $arg1\r" send -- "exit\r" expect eof
space_state.sh
#!/bin/bash USERS=`./sshlogin.exp <PASSWORD> 192.16 8.88.2 sh stations | grep -c Bitlair` STATE=`cat /tmp/spacestate 2>/dev/null` if [ $USERS -gt 0 ]; then if [ "$STATE" != "open" ]; then echo "WE MOETEN OPEN" echo "open" > /tmp/spacestate fi fi if [ $USERS -lt 1 ]; then if [ "$STATE" != "dicht" ]; then echo "WE MOETEN DICHT" echo "dicht" > /tmp/spacestate fi fi