LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 01-05-2012, 09:58 AM   #1
ShadowAce
LQ Newbie
 
Registered: Jan 2012
Posts: 8

Rep: Reputation: Disabled
Expect/bash scripting issue


I have used basic Expect for a couple of months now in the process of administering several hundred servers.

I have a script that will log in to a remote server and execute a command. This is successful.

What I would like to do now is perform that same task, but return a value to the original system for use in calculations. For instance:

expect {
"]#" {send "multipath -ll | grep -A 6 size= | grep active | grep ready | wc -l\r"}
}

will run fine and display the number of SAN connections the remote server currently has.

However, I would like to return that value into a variable on the local system for calculations as the remote servers (this is running through a large list of remote servers) do not necessarily have the same number of SAN connections. I need to be sure that all connections are good, so I need to run a remote command to get the number of seen disks, and the number of multipath paths come back to the original script, perform calculations and pronounce the server as good or bad.

This all requires commands run on remote servers, but using local variables.

Has anyone done this in expect? Can it be done?
 
Old 01-05-2012, 10:19 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Have you thought about using tcpdump or ssh for something like this? I'm thinking more of a way of having your servers connect back, to a separate script, and feed in your information. Just a thought though..... What do you think? Unless there is an easier way of doing this, but having several hundred like you said, this might be a more feasible way of doing......

Cheers,

Josh
 
Old 01-05-2012, 10:27 AM   #3
ShadowAce
LQ Newbie
 
Registered: Jan 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Hmm--ssh from the remote server back to the local server using expect...

I hadn't thought of that approach. Let me mull it over a little more to see what I can come up with.
 
Old 01-05-2012, 10:54 AM   #4
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Remember... Just a thought!
 
  


Reply


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
[SOLVED] bash scripting question root cron issue mindcontrolusa Linux - General 5 12-02-2010 08:57 AM
[SOLVED] Bash scripting issue tubaboy Linux - Newbie 5 11-15-2010 07:41 AM
[SOLVED] /usr/bin/expect : Script to check server load using both expect and bash Soji Antony Programming 1 07-27-2010 11:27 PM
bash scripting issue thesav Programming 7 06-20-2009 02:38 AM
Looping issue in bash scripting ZAMO Linux - General 4 09-26-2008 11:22 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:14 PM.

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
Open Source Consulting | Domain Registration