我需要在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'
关于可能导致此问题或如何解决的任何想法?谢谢
答案 0 :(得分:0)
我发现heredocs有助于避免引用地狱
expect << 'END_EXPECT'
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
END_EXPECT