linux - 如何单行执行此 "expect"命令?

标签 linux bash

我想单行本

#!/usr/bin/expect
spawn ssh-copy-id -i .ssh/id_dsa.pub root@testip
expect "Are you sure you want to continue connecting (yes/no)?"
send -- "yes\r"
expect eof

我认为应该是

/usr/bin/expect -c 'expect "\n" { eval spawn ssh-copy-id -i .ssh/id_dsa.pub root@testip; expect "Are you sure you want to continue connecting (yes/no)?"; send -- "yes\r" }'

但事实并非如此。

谁能看出它应该如何?

最佳答案

也许你不再需要它了,但它应该是这样的:

/usr/bin/expect -c 'spawn ssh-copy-id -i .ssh/id_dsa.pub root@testip ; expect "Are you sure you want to continue connecting (yes/no)?" ; send -- "yes\r" ; expect eof'

关于linux - 如何单行执行此 "expect"命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12215596/

相关文章:

arrays - 遍历 bash 中的数组列表

linux - bash 中的 if else 条件循环

php - 在没有网络服务器的情况下在 linux 上使用 php 从文件夹发送电子邮件

linux - Ubuntu 中的 PATH 变量设置在哪里?

linux - wget redownload 从开始未完成的文件下载并继续下载剩余的文件

node.js - 我使用 npm -g 安装的包没有显示在 bash 脚本中,为什么?

javascript - 如何测试服务器代码是否可以处理来自 10,000 个 Raspberry Pi 的请求?

python - 主机命令和 ifconfig 给出不同的 ips

linux - 打印最后一个斜杠后的文本

python - 对 python 导入感到困惑