3

I am trying to overwrite some directories with content in them on a remote location using pscp to a remote location. I use root user (root@locationServerName). It succeeds in most of them, but fails in some of them returning $? = 1.

The output of the command looks like that:

Sending file filename1.txt, size=2990
filename1.txt             |          2 kB |   2.9 kB/s | ETA: 00:00:00 | 100%
Sending file filename2.txt, size=2665135
filename2.txt: unable to open /path/to/file/location/filename2.txt: failure
Sending file filename3.txt, size=2990
filename3.txt             |          2 kB |   2.9 kB/s | ETA: 00:00:00 | 100%

It looks like for some reason it can't overwrite the files, but I can't figure why or how could I fix it. Running it in verbose mode, doesn't say anything helpful. If I delete the files manually on the target location, then the operation succeeds.

Any ideas?

eddyP23
  • 243
  • 4
  • 11

2 Answers2

6

I have been told this is the solution to that problem, at least to the same unable to open...failure error.

You have to quote the unix-style path:

pscp.exe -r C:\data user@server:"/home/user/path/"
Scott Tiger
  • 161
  • 1
  • 2
  • 2
    I thought this might only be necessary if there are spaces in the unix path, but I needed the double quotation marks even with no spaces. (I am not sure if this is an answer to OP's question, but google brought me here for the "unable to open .. failure" error, and it solved my problem.) – craq Sep 18 '18 at 22:46
  • I also got the "Unable to open... failure" error, but I could remove the quotes without issues. My problem was that the path didn't exist. Double-check that the path already exists, `gcloud compute scp` will not create non-existing directories for you. – Adrian Wiik Jun 08 '23 at 06:51
2

I spent a good 20 minutes trying to figure out why I was getting the error

pscp: unable to open /tmp/filename: failure

Turns out I was out of disk space...

Check disk space with

df -h
EzPaulZ
  • 21
  • 1