SFTP batch not renaming file with "put"

I have a .ksh script that creates an sftp batch file and runs it through sftp. It works except for one thing. If I try to "put" to a different name, it doesn't use the specified remote name...it still "puts" the original local name.

I've tried both of these, and neither work...it will always put the local name to the remote path:

cd  remotepath
lcd localpath
put localfile remotefile
put localpath/localfile remotepath/remotefile

Have you tried:

cd  remotepath
lcd localpath
put localfile
mv remotefileA remotefileB

Or to create a 'tempfile' with the proper name in advance (local), upload that and delete it when done.

hth

1 Like

The mv command doesn't work either...no error or warning...simply does nothing.

I modified my script to copy and name change the file to a local working folder, then sftp and that works...just weird that the put and mv in sftp aren't working.

Looking forward to the day where I don't have the option of renaming the file locally...:mad:

There is a known bug that stops rename working correctly if the underlying filesystem doesn't support hard links:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=308561

So unless you can have ssh updated to a newer version on the receiving system you may have to stick with the local rename before transfer workaround.

However, due to the POODLE SSLv3 vulnerability you may have a good case to request the receiver updates their ssh version.

1 Like

That's good to know.

As for upgrading, I work for a major corporation with dozens of Unix servers all over the country all run by different people, different expense codes, different versions of the OS, etc, etc...so I'll grow wings and fly to Mars before I'll be able to get them to upgrade anything.

:smiley: