远程 ls 输出不会重定向到文件



当我运行下面的代码时,我收到此错误

bash:/var/out.txt: 没有这样的文件或目录

#!/usr/bin/expect
set timeout -1    
spawn ssh user@10.103.234.1 'ls -t /var/backups/archives/' > /var/outp.log    
expect "user@10.103.234.1's password:"    
send "Passwordn"    
expect eof
if [catch wait] {    
    puts "failed"    
    exit 1    
}
exit 0

期望/Tcl 不理解重定向 ( > ( 字符。 试试这个:

spawn bash -c "ssh user@10.103.234.1 ls -t /var/backups/archives/ > /var/outp.log"

使用三通替换spawn ssh user@10.103.234.1 'ls -t/var/backups/archives/|tee -a/var/outp.log'

最新更新