Expect question - send commands to an xterm shell
Posted by dvorak_user (dvorak_user), 4 February 2008EDIT: I've found a better way to write my program, so this is no longer an issue for me. However, I would still like to know how to send commands to a shell in a separate xterm window. Much obliged!
Hello, all! Well, I barely squeezed that title in!
Right now, I'm trying to spawn a shell within an xterm window and then send it commands via Expect. I know how to spawn a shell and send commands through Expect normally, but for the program I'm writing, it would be extraordinarily useful to have information display in a separate window. The closest I've managed to get is with this snippet from Exploring Expect:
However, this code does not yield the desired effect; with this setup, I can only interact with the shell via user input, but I want to retain the ability to send commands directly from a program. Any I/O redirection I've tried has ended up with a nonfunctional program.
Again, my goal is to spawn a shell that displays in an xterm window and send commands - that will also display in the xterm - via another program.
Any help would be sincerely appreciated. Thank you!
edit: I'm not sure how clearly I stated what I'm trying to code, so I thought I'd be more explicit.
*A program should be able to send commands to the shell and expect things from the shell directly (or via xterm) and display the entire transaction in an xterm window.
*The user will occasionally have to interact with the shell - this should be done via the same xterm window.
Again, thanks for reading!
Posted by admin (Graham Ellis), 5 February 2008Thank you for adding those extra bits on the end. Can I ask a question wider still about the application - I'm not exactly sure that Expect is the way to go. It rather looks to me as if you have a project / practical question to answer for an assignment under which a degree of interaction is needed, and I'm going to question the whole basis of your coice of Expect - I wonder if it's a needless level. And I'm wondering what the setter of the task requires / intended, and whether he / she can provide further feedback.
Posted by dvorak_user (dvorak_user), 5 February 2008Thanks for your reply! I'll try to explain the situation as best as I can:
I used a shell as an example, but ideally this script is going to manage a telnet session. There will be four overall, and there needs to be communication among them; I figured that I'd just write one central program to manage four windows and the appropriate Expect commands. The telnet sessions are to separate related programs, and, ideally, Expect will handle a particularly monotonous daily test that needs to be done for some software.
A large degree of automation would significantly speed up the process, but some interaction is required - mainly to manually check configuration settings. Apart from that, user interaction is small. The choice of separate xterm windows (or xterm windows at all) is based on the fact that each telnet session will be displaying several large configuration files and statistics at once, and it would be useful for the user to be able to see all of it at once.
Upon more consideration, I could probably scrap the user interaction bit of the program, but it is still highly desirable to display the automation in an xterm window. The main issue I have is that this program needs to communicate to others, often waiting until one is done with a particular process.
I sincerely appreciate your time, and I'll do what I can to make a solution as easy-to-find as possible.
Posted by admin (Graham Ellis), 6 February 2008From your ongoing description, I would be so tempted to use text areas in Tk - much more controllable and easier
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho