Results 1 to 5 of 5

Thread: [SOLVED] ssh using expect does not show up as expected maximized

  1. #1
    Join Date
    Nov 2006
    Beans
    Hidden!

    [SOLVED] ssh using expect does not show up as expected maximized

    I am writing an application(pygtk) that requires me to ssh to a server and interact with it. I am using expect to login automatically
    My problem is if I run the following in a gnome-terminal window (unmaximized)
    Code:
    $ expect myscript.exp
    and then after it logins to ssh if I maximized(or resize) the window, the text does not show up correctly. for e.g. If i run top the output does not scale and shows up only as half screen ( I have attatched a screenshot)

    If it helps here's the myscript.exp
    Code:
    #!/usr/bin/expect -f 
    set timeout -1
    set server xxx.xxx.xxx.xxx
    set user xxx
    set passwd xxx
    set port  xxx
    spawn /usr/bin/ssh $user@$server -p $port
    match_max 100000
    expect "*(yes/no)?*" {send "yes\r"; exp_continue} \
     "*?assword:*" {send "$passwd\r"}
    send "\r"
    interact
    If I run the command in a maximized window it works as expected. I am beginning to think its a problem(bug) with expect. I have tried both the repository version and the compiled it manually from the website
    All I could find in google related to this was
    http://coding.derkeiler.com/Archive/...5-02/0252.html
    Attached Images Attached Images

  2. #2
    Join Date
    Jun 2006
    Location
    Gwangju, Korea
    Beans
    3,479

    Re: ssh using expect does not show up as expected maximized

    SIGWINCH is the signal that notifies programs that their window has changed size. I wonder if that signal isn't making it through.

  3. #3
    Join Date
    Nov 2006
    Beans
    Hidden!

    Re: ssh using expect does not show up as expected maximized

    Quote Originally Posted by mssever View Post
    SIGWINCH is the signal that notifies programs that their window has changed size. I wonder if that signal isn't making it through.
    thanks, I tried
    kill -SIGWINCH $$
    kill -WINCH $$

    but both did not help. Should I file in a bug report?

  4. #4
    Join Date
    Mar 2006
    Beans
    199

    Re: ssh using expect does not show up as expected maximized

    You have to trap SIGWINCH in your expect script and propagate this to the child.

    Add the following to your expect script:
    Code:
    trap {
     set rows [stty rows]
     set cols [stty columns]
     stty rows $rows columns $cols < $spawn_out(slave,name)
    } WINCH
    Take the following script for example:
    Code:
    #!/usr/bin/env expect
    
    #trap sigwinch and pass it to the child we spawned
    trap {
     set rows [stty rows]
     set cols [stty columns]
     stty rows $rows columns $cols < $spawn_out(slave,name)
    } WINCH
    
    set username yourUserNameHere
    set pass yourPasswordHere
    set host theIpAddressToConnectTo
    
    spawn ssh ${username}@${host}
    
    expect -re "password:"
    send "${pass}\r"
    
    expect -re "$"
    
    # now interact with the session
    interact

  5. #5
    Join Date
    Nov 2006
    Beans
    Hidden!

    [SOLVED] Re: ssh using expect does not show up as expected maximized

    Quote Originally Posted by supirman View Post
    You have to trap SIGWINCH in your expect script and propagate this to the child.

    Add the following to your expect script:
    Code:
    trap {
     set rows [stty rows]
     set cols [stty columns]
     stty rows $rows columns $cols < $spawn_out(slave,name)
    } WINCH
    Take the following script for example:
    Code:
    #!/usr/bin/env expect
    
    #trap sigwinch and pass it to the child we spawned
    trap {
     set rows [stty rows]
     set cols [stty columns]
     stty rows $rows columns $cols < $spawn_out(slave,name)
    } WINCH
    
    set username yourUserNameHere
    set pass yourPasswordHere
    set host theIpAddressToConnectTo
    
    spawn ssh ${username}@${host}
    
    expect -re "password:"
    send "${pass}\r"
    
    expect -re "$"
    
    # now interact with the session
    interact
    Ah that fixed it. Thanks guys

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •