LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 07-27-2010, 08:17 AM   #1
Soji Antony
Member
 
Registered: Jul 2010
Posts: 54

Rep: Reputation: 1
/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
 
Old 07-28-2010, 12:27 AM   #2
Soji Antony
Member
 
Registered: Jul 2010
Posts: 54

Original Poster
Rep: Reputation: 1
mmmmmmm
 
  


Reply

Tags
expect, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Expect script: how do i send function key F12 in an expect script alix123 Programming 4 09-01-2013 10:06 PM
Embed expect in bash script prpednek Linux - General 3 05-15-2010 07:36 AM
can expect be called from within a bash script? johnpaulodonnell Programming 4 06-21-2007 10:42 AM
Combined bash and expect script Paul77 Linux - Software 11 03-08-2007 10:17 AM
SMTP/MX Check Expect Script rk4k Programming 2 02-06-2007 10:36 PM


All times are GMT -5. The time now is 10:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration