文件复制并追加到远程计算机:猫错误 [英] Copy and append files to a remote machine: cat error

查看:169
本文介绍了文件复制并追加到远程计算机:猫错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有一个有点问题:

So, I have a bit of a problem:

本来我是用 SCP 将文件从本地计算机复制到远程机器之前,我意识到,SCP覆盖,而不是追加。但我需要它来追加。所以,我做了一些谷歌搜索,并使用这种替代 SSH 弹出来代替:

Originally I was using scp to copy a file from a local machine to a remote machine before I realized that scp overwrites instead of appends. But I need it to append. So I did some Googling and this alternative using cat and ssh popped up instead:

cat localfile | ssh user@remoteserver "cat >> remotefile"

问题是,每当我使用的方法,我得到这个有趣的错误:

Problem is, I get this interesting error whenever I use that method:

bash: cat: command not found

当我通常ssh到我的远程机器,我可以就好了,所以我在寻找任何有助于解决这个问题,或者找到一种方法只使用追加从我的本地主机的命令。

When I normally ssh into my remote machine, I can cat just fine, so I'm looking for either help fixing this problem or finding a way to append using only commands from my local host.

推荐答案

$ PATH 通过ssh运行时,可能会有所不同。

Your $PATH may be different when running through ssh.

无论如何,你可以运行要找到猫,其中实际上是放置在远程机器和硬$上C $ c。在命令调用的路径。例如

Anyway, you can run which cat to find where cat is actually placed on the remote machine and hard code the path in the command invocation. For instance

ssh user@remoteserver "/sbin/cat >>remotefile" <localfile

(顺便说一句,你并不真正需要的地方)。

另一种选择是使用SFTP客户端支持附加。

Another option would be to use a SFTP client with support for appending.

这篇关于文件复制并追加到远程计算机:猫错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆