| |||||||||||
staring an xetrm Posted by kannarv1 (kannarv1), 17 March 2006 hi ,from expect script i login to a device and i need to start a xterm window ,and tail a file in that window.is it possible to do that . after loggin into mac i could not bring up xterm window and tail the file ..any suggesions ho w to go abt. proc openxterm { rtp Prompt Login Passwd } { send -- "$TELNET $rtp\r" while (1) { expect { "Last *\n" { continue } "ogin: " { send -- "$Login\r" continue } "assword: " { send -- "$tPasswd\r" continue } "unknown host" { errLog $func "3. Unknown host $thost" return -1 } "*incorrect input" { errLog $func "4. Login failed invalid login name or passwd ... " return -1 } "*incorrect" { errLog $func "5. Login failed (invalid login name o passwd) ..." return -1 } "user1$" { send -- "xterm &" break } } send -- "set +o vi\r" send -- "set +o emacs\r" return 0 } thnaks for the help Posted by admin (Graham Ellis), 18 March 2006 Why do you need an xterm? Can't you do what you want from the command line?If you try to bring up an xterm, you need to trap your inputs and outputs, and / or if you do it the way you show, you need to set up the xhost permissions so that the window is allowed on the remote screen, or set DISPLAY back to yourself. Quite a bit to do there and probably un-necessary! And if the remote machine is a mac, it probably doesn't have xterm anyway . Tell us more about what you're trying to do, and what actually goes wrong. Posted by kannarv1 (kannarv1), 20 March 2006 thanks for the help graham.(From my prev post) i have created a log file . I have a soalris box i need to telnet ino the system start an xterm and tail the log file thru xterm.there is not going to to be any mac machine and its going to be jus solaris box . i could not bring up the xterm..hoe iam clear. thanks fo rthe help Posted by admin (Graham Ellis), 20 March 2006 OK - but why do you need the xterm? Why can't you run through a shell?Posted by kannarv1 (kannarv1), 21 March 2006 by default all the system where the script is going to run has an xterm and already there will u other scripts running from shell so to diff the log file i planned to use an xterm and tail the fail .i tried to popup a new console after telnet in to the sys..but no use . i could not get xterm to pop up. part of code is below . set TELNET "telnet" set tgtdevice "xxx.xx.xx.xx" set tgtPrompt "$" set tgtLogin "xxxx" set tgtPasswd "xxxx" set xterm "xterm" proc openSession { tgtdevive tgtPrompt tgtLogin tgtPasswd } { # send -- "$TELNET $tgtdevice\r" spawn $TELNET $tgtdevice while (1) { expect { "Last *\n" { continue } "ogin:" { send -- "$tgtLogin\r" # puts "1. Send login name $tgtLogin ..." continue } "assword:" { send -- "$tgtPasswd\r" # puts "2. Sent passwd name ..." break } } } send -- "\r" return 0 } proc launchxterm { } { # send -- "xterm\r" expect { "*$" { send -- "xterm\r" puts " xterm session started" return 0 } "*STREAM INITIALIZED *" { puts "4. problem in xterm started" return -1 } } return 0 } if { [eval openSession $tgtdevice $tgtPrompt $tgtLogin $tgtPasswd] } { puts "xxxxxx" } if { [eval launchxterm] } { puts " xxxxxx " } thanks for all th ehelp Posted by kannarv1 (kannarv1), 22 March 2006 ok now i tried to login to sunbox start a new shell and tried to tail the fail ..but it dint work ... any help ...thanksPosted by admin (Graham Ellis), 26 March 2006 I remain unconvinced that xterm is the right vehicle for you and would suggest a second spawned process or a subshell in the existing one might be easier. However, I don't fully understand your application and so I may have missed something ...Xterms bypass the standard /dev/tty handler, so can't be spawned and work in the "usual" way. You can either pop up the xterm from within another script, using the -e option on that command to route the information back, or you can spawn -pty and manipulate the spawn_out variable yourself. In any case, you also need to be aware of xhost and DISPLAY and have those set properly - otherwise you'll end up poooping the window on the wrong screen - or rather trying to do so and hitting a security gate that stops you. There's much more on this topic in Exploring Expect by Don Libes - start at page 293 for the specifics. This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |