Using #!/usr/bin/expect and bash

好久不见. 提交于 2020-02-08 08:28:35

问题


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?


回答1:


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




回答2:


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


来源:https://stackoverflow.com/questions/21997554/using-usr-bin-expect-and-bash

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!