Copy and append files to a remote machine: cat error

瘦欲@ 提交于 2019-12-22 00:34:15

问题


So, I have a bit of a problem:

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

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.


回答1:


Your $PATH may be different when running through ssh.

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

(BTW, you don't really need the local cat).

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



来源:https://stackoverflow.com/questions/13650312/copy-and-append-files-to-a-remote-machine-cat-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!