Friday, October 10, 2014

I mentioned a SSH library called pexpect which let's you pipe stdin and stdout. Similarly psppass can be invoked from a bash script as well :



#!/bin/bash

# CRUD.sh of resource over SSH

#

if [ -z "$1" ]

then

echo "Usage: `basename $0` [create|update|delete|list] [resource] [rule]"

exit $E_NOARGS

fi


share_=$2_

rule_=$3_

create_Command="create resource"

delete_Command="delete resource"

list_Command="list resource"


case $1 in

"create" ) Command=""$create_Command"" ;;

"update" ) Command=""$update_Command"" ;;

"delete" ) Command=""$delete_Command"" ;;

"list"   ) Command=""$list_Command"" ;;

* ) echo "Usage: `basename $0` [create|update|delete|list] [resource] [rule]" ;;

esac


export SSHPASSpassword # use keys instead

sshpass -e ssh -oBatchMode=no root@xyz.com""$Command""

exit $?

OK now where did I leave the change from the bus ride today?

No comments:

Post a Comment