Skip to main content

Using except command with bash

1.Use the interpreter for bash at first line .

#!/bin/bash

2. Use variables as per requirement and pass it to except if needed.

HOST="localhost"
USER="chitti"
PASS="123"
CMD=$@


3. Use expect script as required.

XYZ=$(expect -c "
spawn ssh $USER@$HOST
expect \"password:\"
send \"$PASS\r\"
expect \"\\\\$\"
send \"$CMD\r\"
expect -re \"$USER.*\"
send \"logout\"
")


4.Print the result of except using echo like

echo "${XYZ}"

Comments

Popular posts

Hipchat and Icinga

Hipchat Notify 2.0 Hipchat notification with API 2.0 to be used with ICINGA/Nagios Table of Contents Table of Contents Author Audience Introduction Ruby Script Script used on server Service notification Host notification Change in command.conf for Icinga server Example notification Roadmap Author Shubhamkr619@gmail.com Audience System Engineers and operation engineers Introduction Change the default mail notification of Icinga server to hipchat notification using ruby code. This will allow a single place of management of all the notification and alerts across organization. Let that be service,host or business level alerts all can be managed and monitored using hipchat and hubot will give certain advantage over traditional alerting system. Proactive and reactive alerting Managed monitoring Single place of all the alerts Better communication and collaboration Integration with multiple tools in CI cycle Jenkins Chef ...

Enter your email address: