ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I've run into an issue that I cannot resolve and Google seems to be no help, either. Hopefully, one of you gurus can help me out here:
I've been writing a bunch of expect scripts to perform functions on remote servers in our environment. Part of every script is the login process, which can get pretty tedious (it's a double login with multiple passwords).
While the login process works, it takes up a lot of space in each script. I'd like to push it off into a Tcl package, and it almost works. My new script now calls login $server and it will login to the remote server, but then it just hangs.
What I'm trying to do is similar to the following:
My login script does NOT have an "expect eof", but it does have the following:
expect {
"#" {return}
}
However, somwhere between the end of the login $server line and the first expect, it just hangs. It does display the root prompt on the remote server, showing that the login was successful.
Is this an issue with process ids, threads, or something else?
How can I get my parent script to recognize the output from the login script to continue processing from the remote server?
Distribution: RHEL 5.1 on My PC, & SunOS / Sun Solaris, RHEL, SuSe, Debian, FreeBSD and other Linux flavors @ Work
Posts: 400
Rep:
You need "ssh-keygen" to generate keys that you can share with the remote servers. Then you will need to do "ssh Demo@ExampleServer.com command_or_script" and it will return back from the server giving you the output of your command/script if it produces any.
First work on them and then let us know if you need more help. I am not familiar with Tcl so I do not know your codes above. But using the method I have specified above you can simply get a listing of files by issuing this command:
Code:
ssh Demo@ExampleServer.com ls -ltr /root
More Examples:
Code:
output=`ssh Demo@ExampleServer.com 'uptime; free'`
echo "System Health Info"
echo "$output"
I appreciate you taking the time to reply. However, using ssh keys is not allowed in this environment.
I am familiar with the method you describe, and I would love to do it that way, but it is not politically feasible at this time.
I need to be able to log in, then be able to perform 1 or more commands. The "ls -ls" command in the OP was just an example. It needs to be able to perform a whole series of commands, if required.
Hmm, I guess there aren't many expect experts on this forum, it might be easier to help if you could give a small self-contained example to demonstrate the problem.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.