【发布时间】:2019-10-26 19:05:00
【问题描述】:
我需要在带有 ssh 的脚本中使用 find 命令并一起查找。像这样的:
expect -c "
spawn ssh user@host \"find api -type f -name *.html -mtime +30 -exec rm -rf {} \;\"
expect {
\"*password\" {set timeout 300; send \"mypassword\r\";}
}
expect eof"
我明白了
find: missing argument to `-exec'
对可能导致此问题的原因或如何解决此问题有任何想法吗?谢谢
【问题讨论】:
-
你应该按照上面的建议重写你的脚本,因为你需要用
\\\;替换\; -
@meuh,只需要 2 个反斜杠。或使用单引号保护分号。
-
@meuh 你是对的。有用 。非常感谢。
-
看看sexpect (Expect for Shells),您可以使用它来编写仅使用shell代码的Expect脚本。
标签: shell ssh find exec expect