【问题标题】:Sending file by reference to a remote server?通过引用远程服务器发送文件?
【发布时间】:2014-07-20 22:11:15
【问题描述】:

尝试通过引用发送文件或以某种方式在远程服务器上附加文件。

使用 scp 现在只发送文件的副本。我的代码没有意义,因为我正在发送文件的副本,但我无法对它做任何事情,因为它不会更改原始文件。

while read p;do
    scp sample_file.txt $p"./home/user"
    #Log onto remote server
    #Get last entry of directory and put it in sample_file.txt
done <usernames_list.txt

基本上我希望 list_of_stuff.txt 看起来像

entry1
entry2
entry3
entry4
...etc

有谁知道如何将实际文件(而不是只发送安全副本的 scp)发送到 UNIX 中的远程服务器?或者有谁知道如何在远程服务器上追加?

【问题讨论】:

  • “发送实际文件而不是……安全副本”是什么意思?
  • usernames_list.txt 中的行是什么样的?

标签: linux bash unix


【解决方案1】:

从事物的声音来看,您根本不需要将文件复制到远程服务器!您只需要在该服务器上运行某些命令的输出即可将其附加到文件中,因此您可以通过管道从ssh 的输出在本地执行此操作:

while read p; do
    ssh $p "get_last_entry_of_directory" >> sample_file.txt
done < usernames_list.txt

我已经把命令 get_last_entry_of_directory 弄出来了,因为我不确定那里应该涉及什么。

【讨论】:

    猜你喜欢
    • 2021-12-27
    • 2021-07-06
    • 2013-05-04
    • 1970-01-01
    • 2019-01-25
    • 2021-06-26
    • 2012-08-27
    • 2012-05-04
    • 1970-01-01
    相关资源
    最近更新 更多