远程ls输出未重定向到文件

时间:2018-01-05 07:36:06

标签: linux bash shell expect

当我运行以下代码时,我发现了这个错误

  

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

CREATE TEMPORARY TABLE "Tablename_20171024_115736_814_1" 
AS SELECT "column1","column2","column3"
FROM "database"."schema"."table" WHERE FALSE

2 个答案:

答案 0 :(得分:0)

Expect / Tcl不了解重定向(>)char。试试这个:

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

答案 1 :(得分:0)

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