/usr/bin/expect : Script to check server load using both expect and bash
Hello...I am trying to make a script that can be used to check server load on a remote server and produces sound on our local machine, when server load exceeds a particular limit.
1. I want to execute command uptime or uptime | awk '{print$10}'on the remote server and store the result in a variable(say x), and later use it in the bash script.
Bash Part
------------------------------
#!/bin/bash
x=$(/root/Desktop/exp)
echo $x
------------------------------
/root/Desktop/exp is my expect script
------------------------------
Expect part
#!/usr/bin/expect
spawn ssh 192.168.0.1
expect "*?assword:*\r"
send "redhat\r"
expect "%"
send "uptime\r"
expect "%"
send "logout"
expect "%"
------------------------------
I thought that echo $x will echo "uptime output in the remote server". But it does not happen.....Please help....Thanks in advance....soji
|