2

I am trying to print file names along with path from SFTP server to other location. I am able to get file names but not path. Below is the code that I have used:

echo "ls *.gpg" | sftp [email protected]:/SXMPMX/INBOUND/FORDCOI_CONT_RESP > $Path/sample.txt

Please let me know is there any way to solve my problem.

1 Answer 1

0

In general many things can get easier with FUSE.

Use FUSE and deal with paths locally, using local tools like find. This is very similar to my another answer about FTP, you just need sshfs instead of curlftpfs.

Having a SFTP share mounted under e.g. /some/mountpoint/, cd to where you want and use

realpath --relative-to /some/mountpoint/ *.gpg

Example:

$ sshfs [email protected]:/ /some/mountpoint/
$ cd /some/mountpoint/SXMPMX/INBOUND/FORDCOI_CONT_RESP
$ realpath --relative-to /some/mountpoint/ foo.gpg   # assuming the file exists
SXMPMX/INBOUND/FORDCOI_CONT_RESP/foo.gpg
1
  • In local i can able to print file name with path by using readlink -f *.txt command. i wanted to print the file name and path from SFTP.
    – Midhun
    Feb 8, 2018 at 8:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .