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 xfer@nsb.abc.com:/SXMPMX/INBOUND/FORDCOI_CONT_RESP > $Path/sample.txt

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

Cyrus
  • 5,751
Midhun
  • 121

1 Answers1

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 xfer@nsb.abc.com:/ /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