sftp & Openssh limitation : can't rename file via ssh
Posted on 2011-09-29
From my ssh client (on a Linux box) I would sftp to a remote Windows
2003 box (running Openssh server).
However using Shell scripts,
sftp> rename file1 file1.bak
sftp> put file1
However, the rename command would fail if file1 does not
exist on the remote Windows end & this would cause the
subsequent commands (including the put) to fail.
Alternatively, I can code my script to do as follows :
ssh remoteid@remote_IPaddr 'cd directory; rename file1 file1.bak'
but the above rename fails when coded as in the above in my
Linux shell script : it says command not found but this rename
command works (ie managed to rename file1 if I ssh manually
into the remote server to issue it manually; not if it's automated
in a script).
I've found a GNU utility mv.exe (for Windows) which would allow my
Linux Shell script to work ie
ssh remoteid@remote_IPaddr 'cd directory; mv file1 file1.bak'
But alas, due to security reason, the remote end (which is a
military related organization) won't allow freeware / GNU /
Open source tools to be installed/loaded there
So what other options do I have now to automate remote renaming
of file via sftp/scp/ssh ?