gpt4 book ai didi

linux - 通过引用发送文件到远程服务器?

转载 作者:太空宇宙 更新时间:2023-11-04 03:55:28 25 4
gpt4 key购买 nike

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

使用 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 中的远程服务器?或者有谁知道如何附加到远程服务器上?

最佳答案

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

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

我已经模拟了命令 get_last_entry_of_directory 因为我不确定那里应该涉及什么。

关于linux - 通过引用发送文件到远程服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24855407/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com