使用 expect 完成自动交互的3种方式
参考文档:Shell 编程 免交互 expect
expect脚本
编写以 #!/usr/bin/expect 开头的脚本,缺点是只能执行 expect 相关命令,不能执行 ls, pwd 等其他命令。示例:
#!/usr/bin/expect
set timeout 30
# 上传文件到服务器
spawn scp target/test-service.jar [email protected]:/root
expect "[email protected]'s password: "
send "
原创
2020-12-02 11:21:57 ·
365 阅读 ·
0 评论