Help me manage Zmodem over ssh with the wait

There is an excellent little zssh tool there , which simplifies the use of a lszrzutility to transfer files using zmodem over an existing ssh connection. This is surprisingly convenient ... but it seems that I must in order to accomplish the same thing using expect. I got it far ...

#!/usr/bin/expect -f

spawn ssh $argv
set ssh_spawn_id $spawn_id
send_user "ssh is: $ssh_spawn_id\n"

interact -o "\030B0000" {
    send_user "\nStarting zmodem receive.\n"

    spawn rz -v
    set rz_spawn_id $spawn_id
    send_user "rz is: $rz_spawn_id\n"

    while {1} {
        expect {
            eof break

            -i $rz_spawn_id -re .+ {
                send -raw -i $ssh_spawn_id $expect_out(buffer)
            }
            -i $ssh_spawn_id -re .+ {
                send -raw -i $rz_spawn_id $expect_out(buffer)
            }
        }
    }

    send_user "\nFinished zmodem receive.\n"
    set spawn_id $ssh_spawn_id
}

This run rzafter viewing the frame ZRQINIT, and it apparently connects rzto the ssh session, but it does not work. rzHe speaks:

Retry 0: Bad CRCe.**B0100000023be50
Retry 0: Bad CRC**B0600000023d984
Retry 0: Bad CRC**B0600000023d984

... etc.

Is there any way to make this work? Thank!

+3
source share
2 answers
  • exp_internal 1, . , .

  • , . rz stty raw. send_user "Finished..." do stty -raw.

  • exp_continue while:

    spawn rz -v
    set rz_spawn_id $spawn_id
    send_user "rz is: $rz_spawn_id\n"
    
    expect {
        -i $rz_spawn_id -re .+ {
            send -raw -i $ssh_spawn_id $expect_out(buffer)
            exp_continue
        }
        -i $ssh_spawn_id -re .+ {
            send -raw -i $rz_spawn_id $expect_out(buffer)
            exp_continue
        }
        eof
    }
    

    , .

+2

, -e/--escape ( ) , zmodem.

:

:

sz -e somefile.ext

:

rz -e

IPMI sol (serial-over-lan).

iterm2-zmodem OSX Konsole Linux Zmodem.

+2

Source: https://habr.com/ru/post/1792561/


All Articles