Issue with using -filemask to exclude sub-directories
Hello,
I am attempting to exclude sub-directories (using –filemask) when retrieving files from a specified directory. I am putting together a script to be called by an SAP call to WinSCP. I want this script to be generic so that I can pass it any folder structure (via parameters passed in the SAP call).
Suppose the remote server directory structure is like the following:
/ (home or root directory)
/testA.txt
/OUT
/OUT/testB.txt
/OUT/next
/OUT/next/testC.txt
I want the chosen file to be written to a folder on my local server (\\Target\Subtarget).
* SCENARIO 1 (this works)
If I log in to the root/home level with an “open” command, use no “cd” command, and issue the following “get” command:
"get -filemask=|*/ * \\Target\Subtarget\"
Then only file testA.txt is retrieved and placed in the Subtarget sub-directory – as desired.
* SCENARIO 2 (this works)
If I log in to the root/home level with an “open” command, issue the following “cd” and “get” commands:
"cd /OUT"
"get -filemask=|*/ * \\Target\Subtarget\"
Then only file testB.txt is retrieved and placed in the Subtarget sub-directory – as desired.
* SCENARIO 3 (THIS FAILS)
If I log in to the root/home level with an “open” command, issue the following “cd” and “get” commands:
"cd /OUT/next"
"get -filemask=|*/ * \\Target\Subtarget\"
Then I am hoping to retrieve file testC.txt. However, nothing is retrieved, and the code executes much more quickly, indicating to me that it probably had an issue with the syntax. The error message I get back from the SAP call to WinSCP isn’t very informative.
Can someone tell me why this last scenario would fail, and how to resolve it?
Using WinSCP 5.5.4 on Windows 2008 R2.
The script being passed to the SAP call for SCENARIO 3 would be:
"open sftp://<username>:<password>@<host> -hostkey=""ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx""" "cd /OUT/next" "get -filemask=|*/ * \\Target\Subtarget\" "close" "exit"
(the call to WinSCP would include option batch abort and option confirm off in addition to the script above)
Thanks.
Stan Brassell
Also... If I leave out the –filemask clause, the desired file is retrieved in SCENARIO 3 – but so are the unwanted subdirectories.
I am attempting to exclude sub-directories (using –filemask) when retrieving files from a specified directory. I am putting together a script to be called by an SAP call to WinSCP. I want this script to be generic so that I can pass it any folder structure (via parameters passed in the SAP call).
Suppose the remote server directory structure is like the following:
/ (home or root directory)
/testA.txt
/OUT
/OUT/testB.txt
/OUT/next
/OUT/next/testC.txt
I want the chosen file to be written to a folder on my local server (\\Target\Subtarget).
* SCENARIO 1 (this works)
If I log in to the root/home level with an “open” command, use no “cd” command, and issue the following “get” command:
"get -filemask=|*/ * \\Target\Subtarget\"
Then only file testA.txt is retrieved and placed in the Subtarget sub-directory – as desired.
* SCENARIO 2 (this works)
If I log in to the root/home level with an “open” command, issue the following “cd” and “get” commands:
"cd /OUT"
"get -filemask=|*/ * \\Target\Subtarget\"
Then only file testB.txt is retrieved and placed in the Subtarget sub-directory – as desired.
* SCENARIO 3 (THIS FAILS)
If I log in to the root/home level with an “open” command, issue the following “cd” and “get” commands:
"cd /OUT/next"
"get -filemask=|*/ * \\Target\Subtarget\"
Then I am hoping to retrieve file testC.txt. However, nothing is retrieved, and the code executes much more quickly, indicating to me that it probably had an issue with the syntax. The error message I get back from the SAP call to WinSCP isn’t very informative.
Can someone tell me why this last scenario would fail, and how to resolve it?
Using WinSCP 5.5.4 on Windows 2008 R2.
The script being passed to the SAP call for SCENARIO 3 would be:
"open sftp://<username>:<password>@<host> -hostkey=""ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx""" "cd /OUT/next" "get -filemask=|*/ * \\Target\Subtarget\" "close" "exit"
(the call to WinSCP would include option batch abort and option confirm off in addition to the script above)
Thanks.
Stan Brassell
Also... If I leave out the –filemask clause, the desired file is retrieved in SCENARIO 3 – but so are the unwanted subdirectories.