LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Expect/bash scripting issue (https://www.linuxquestions.org/questions/programming-9/expect-bash-scripting-issue-922226/)

ShadowAce 01-05-2012 09:58 AM

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?

corp769 01-05-2012 10:19 AM

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

ShadowAce 01-05-2012 10:27 AM

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.

corp769 01-05-2012 10:54 AM

Remember... Just a thought! ;)


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