1

I'm programming a C# .NET console application to retrieve files from an SFTP server. The host posts a new file every day, with 7 days of files in the same directory. The problem is that they use the exact same file name every day (perhaps they're on VMS?) The only difference in the files that I can see through SFTP is the Changed date/time and the file size.

I'm using the Renci.SshNet library to retrieve files. Unfortunately, the only way I have to specify which file to retrieve is by giving it the file name. Since all the files are named the same, it ALWAYS retrieves the newest file.

How can I retrieve any of the previous files?

Mark Petereit
  • 341
  • 2
  • 15
  • That doesn't really make much sense: I can't imagine how you'd have multiple files in a directory with the same name. There'd need to be *some* difference in the name. – David Makogon Nov 17 '16 at 12:53
  • Nope. In fact, if I use an SFTP client to rename one of the files (e.g. to include the date in the name), it renames ALL of the files. As I hinted, I believe the host is on VMS where multiple files with the same name are allowed (differentiated at the OS level by version, I suppose.) – Mark Petereit Nov 17 '16 at 12:57
  • If I remember correctly, `VMS` has a version counter at the end of the filename, separated by `;` (example: `myfile;7`). Have you tried to specify the desired version in the name? – Axel Kemper Nov 17 '16 at 12:58
  • Trivia: The version number separator can be either a semicolon or dot, e.g. `NAME.TYP;42` and `NAME.TYP.42` are equivalent. – HABO Nov 17 '16 at 14:06
  • With sftp from Linux to VMS I can do a get with a version number, like `get name.type;42`. I can also use relative version numbers, like `;0` for the current version and `;-1` for the previous version. – user2116290 Nov 17 '16 at 15:41
  • Ah! Brilliant, @user2116290. My next problem was going to be that even if I could request by version, since I don't see the version numbers on the files, I had no idea what version numbers to request. – Mark Petereit Nov 17 '16 at 16:24
  • Stink! I tried using a command-line sftp program to grab the file with ;0 at the end. Got file not found, so it's apparently NOT a VMS versioning issue. I'm stumped! – Mark Petereit Nov 17 '16 at 21:50
  • With `-v` you should see what the remote system is, and what IP stack is running on that system. I verified that this works with the HP/VMS default IP stack: `debug1: Remote protocol version 2.0, remote software version 3.2.0 SSH OpenVMS V5.5 VMS_sftp_version 3`. On another VMS system with `debug1: Remote protocol version 2.0, remote software version Process Software SSH 6.1.5.0 MultiNet`, a different IP stack, I can get the `;0` version and any other absolute version but no `;-1`. This may not be VMS on the remote system or a (missing) feature of the IP stack running on that system. – user2116290 Nov 17 '16 at 22:42
  • Can you connect with some standalone SFTP client (e.g. WinSCP) and show us its log with a directory listing? – Martin Prikryl Nov 21 '16 at 08:25

0 Answers0