Using #!/usr/bin/expect and bash

2019-08-21 11:59发布

Is there any way I can use bash script along with /usr/bin/expect commands?

Could I, for instance, use an if statement in a usr/bin/expect script?

标签: bash expect
2条回答
手持菜刀,她持情操
2楼-- · 2019-08-21 12:06

expect is an extension of tcl - therefore you can use the programming constructs of tcl - these include 'if'.

Tcl command man pages are available: tcl.tk/man/tcl8.5/TclCmd/contents.htm

查看更多
够拽才男人
3楼-- · 2019-08-21 12:15

Here is a very simple script that connects to a server via ssh from bash:

#!/bin/bash

/usr/bin/expect <<EOF
    spawn ssh user@server
    expect {
        "assword:" {
            send -- "1234\r"
        }
    }
EOF
查看更多
登录 后发表回答