0

I am downloading all files in a directory via SFTP using below syntax:

sshpass -p 'mypass' sftp name@$IP:/var/log/* 

With above one-liner, I'm able to download all files from /var/log

But I want the $IP to be appended with each file name being downloaded

I am able to do it for a per file bases i.e. if I download single file, I can appended the IP before the file name. But as you would have guessed, in some cases I don't know how many files are there and I think it would be an overhead as well if I keep doing SFTP to download one file at a time.

I tried below to download one file with IP appended before the file name:

sshpass -p 'mypass' sftp name@$IP < <(echo "get /var/log/file1.log ${IP}.file1.log" ) 

Also I checked in SFTP shell itself, I am not able to find any sort of loop or parameter expansion. So apparently if there's a way, it has to be like the ones I am trying.

Note: SFTP is the only option, and not scp/rsync etc..

7
  • Why do you believe is SFTP the only option? Jun 27, 2020 at 15:46
  • I know it is, it is a Telecom equipment with very limited functionality
    – Ibraheem
    Jun 27, 2020 at 21:05
  • You mean the client is limited, or the server is limited? Jun 27, 2020 at 21:46
  • The server, From where I want to get the files,
    – Ibraheem
    Jun 27, 2020 at 22:07
  • And these are hundreds of such nodes, from where I want to get the files, these are syslog files, and I want to append the IP (and date) information with each file. I thought of another solution, to create hundreds of directories, unique for an IP, and then download the files from a given IP in it's own directory, but first I want to learn if there is such possibility as I asked in the question or not?
    – Ibraheem
    Jun 27, 2020 at 22:09

0

You must log in to answer this question.

Browse other questions tagged .