0

On a server, the directory structure is already organized like this. (For sake of argument, I can't change it. I can only figure out a way to make it more useful to me.)

/work/product/versions/app-0.98
/work/product/versions/app-1.0
/work/product/versions/app-1.1
/work/product/versions/app-1.2

Inside each directory are several files, for example:

/work/product/versions/app-0.98/app-0.98.1234
/work/product/versions/app-0.98/app-0.98.1235
/work/product/versions/app-0.98/app-0.98.1236
/work/product/versions/app-0.98/app-0.98.1237

When I get a version I like, I want to symlink it to release, like:

ln -s /work/product/versions/app-0.98/app-0.98.1237 /work/product/versions/app-0.98/release

This way, I can always download my validated release by asking for the release file. I download them like this:

scp me@host01:/work/product/versions/app-0.98/release .

On my local filesystem, I am left with a file named "release".

me@host01:/home/me# ls -al
total 528948
drwxr-xr-x 2 me me      4096 Feb  6 12:24 .
drwxr-xr-x 8 me me      4096 Feb  2 13:03 ..
-rwxr-xr-x 1 me me 541627065 Feb  6 12:25 release

I'd like the file to be named the same as the original file, app-0.98.1237. Is there something I can change on my server or in my scp call to save the file using the original file name?

I'm on a variety of OSes, primarily Linux - Debian and CentOS distros.

1

The closest I can come off the top of my head is a two-step process that uses rsync rather than naked scp (rsync can use scp as its back-end):

First, copy the link itself:

rsync -a username@host:/path/to/release .

Then, copy whatever the target might be:

rsync -za username@host:"$(basename "$(readlink release)")" .

You will then end up with this:

$ ls -l
total 0
drwxrwxr-x  3 username  groupname  96 Feb  6 11:10 1.02
lrwxrwxrwx  1 username  groupname   4 Feb  6 11:09 release -> 1.02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.