So i'm trying to upload a file to an SSH server using node. First I try the obvious putFile method provided by the obvious node-ssh package. On any other server this would work fine but this server doesn't have sftp installed so that doesn't work.

OK, so next I learn how scp works (it runs the command "scp -t" on the remote server, and sends to stdin a command like "C0666 1234 file.txt" and then sends the contents of the file) and I write some javascript code to do this. It's pretty finicky, the first few tries I forget to close the stream right or detect the program finishing. I add some logging and that helps me figure out what the problem is, and finally I get it to not output any errors.

So I log into the server and check and the file isn't there. I try again several times, file still isn't there. I try running scp -t manually on the server, typing in exactly what my program is sending, and it works. This goes on for a while until I realize that I've been sending a file to one server and logging into a different server to check if the file was sent. grrr

  • 3
    Do rsync instead
  • 0
    @Linux I just need to copy a file without spending a month learning which rsync flags i need
  • 2


    There you go... It takes 1 minute to figure that out. Please dont touch Linux again if you are not willing to learn.
  • 0
    @Linux apparently that's the same as `-rlptgoD`. don't really want to dig deeper.

    PS: this is ios not linux, and we don't have rsync installed on these ios devices
Your Job Suck?
Get a Better Job
Add Comment