#!/bin/bash                                                                     
                                                                                
if [ "$1" == "-h" ]
then
	echo "$0: help"
	echo " $0 target-host [ target host cmd [default: reboot]]"
	echo "    send cmd to target host and receive output"
	echo "    es. $0 192.168.3.99 "
	echo "        reboot host 192.168.3.99 "
	echo " "
	echo "    es. $0 192.168.3.99 ls -la /home/st"
	echo "        list files in /home/st of target host 192.168.3.99 "
	echo " "
	echo " $0 -h "
	echo "     this help "
	echo ""
	exit 
fi

if [ "$1" == "" ]
then
	echo "$0: no IP given, exit"
	exit 
else
	export DESTINATION="$1"   
fi

if [ "$2" == "" ]
then
	echo "$0: no cmd given, set to default reboot"
	export CMD="reboot"
else
	export CMD="$2"
fi
echo "$0: cmd set to : $CMD"

echo "$0: sending reboot to raspberry IP $DESTINATION..."

sshpass -p "Passy.:1234!" ssh root@$DESTINATION -o StrictHostKeyChecking=no "$CMD"

echo "$0: sent $CMD to raspberry IP $DESTINATION"

