【问题标题】:shell script for checking files at remote scp sever using ssh使用 ssh 检查远程 scp 服务器上的文件的 shell 脚本
【发布时间】:2018-08-29 18:36:45
【问题描述】:

我正在 /temp 目录中的远程服务器上检查文件,并将文件数存储在临时文件中,并对本地服务器执行 scp。 当我在控制台上运行以下命令时,它的运行文件但它在 shell 脚本中不起作用。

ssh id@$remote_sever
cd /temp
ls  *.txt | wc -l > /temp/temp.txt
scp /temp/temp.txt infa_id@local_sever:/TEMP
exit

【问题讨论】:

  • /temp/temp.tx 确定不是错字?

标签: unix ssh


【解决方案1】:

您不需要另一台机器上的临时文件。您可以通过 SSH 执行命令,然后将结果存储在本地:

ssh id@remote_server 'ls /temp/*txt | wc -l' > /TEMP/temp.txt

【讨论】:

    猜你喜欢
    • 2013-01-01
    • 2015-06-01
    • 1970-01-01
    • 2019-06-20
    • 2011-05-05
    • 2013-03-14
    • 2012-10-20
    • 2014-04-08
    • 2012-10-28
    相关资源
    最近更新 更多