I can copy file via SSH by using SCP like this:
cd /root/dir1/dir2/
scp filename [email protected]:$PWD/
But if on remote server some directories are absent, in example remote server has only /root/ and havn't dir1 and dir2, then I can't do it and I get an error.
How can I do this - to copy file with creating directories which absent via SSH, and how to make it the easiest way?
The easiest way mean that I can get current path only by $PWD, i.e. script must be light moveable without any changes.
mkdirnon-interactively as seen in some answers here: stackoverflow.com/questions/1340048/… - Joeman scpand check out the-roption. - lurker