I am able to download files OK using corecmd.exe, but I often have to script the download of multiple files. Is there a way to do this in one call to corecmd.exe rather than calling corecmd.exe for each file I need to download.
Currently I script something like this,
corecmd.exe -site MY_SITE -s -d /remotefile1 -p C:\ftp_download_dir
corecmd.exe -site MY_SITE -s -d /remotefile2 -p C:\ftp_download_dir
corecmd.exe -site MY_SITE -s -d /remotefile3 -p C:\ftp_download_dir
Can I script the download of the multiple files in one call to corecmd.exe? Rather than constantly opening and closing the connection to the remote server?
Note: I do not want to download all files in a remote folder, only specific selected files.
Thanks in advance.
How to download multiple files with Corecmd.exe
-
- Site Admin
- Posts: 1004
- Joined: Mon Mar 24, 2003 4:37 am
use the -scal <scriptfile> option. See help topic "command line" for more info.
<scriptfile> would be a file containing something like this:
For FTP/SSL/FTPS:
CWD /remote_path/
RETR remotefile1
RETR remotefile2
RETR remotefile3
or for SFTP:
RETR /remote_path/remotefile1
RETR /remote_path/remotefile2
If the script hangs, add the QUIT command to the last line.
<scriptfile> would be a file containing something like this:
For FTP/SSL/FTPS:
CWD /remote_path/
RETR remotefile1
RETR remotefile2
RETR remotefile3
or for SFTP:
RETR /remote_path/remotefile1
RETR /remote_path/remotefile2
If the script hangs, add the QUIT command to the last line.
Thanks for your suggestion regarding using a script.
The script is working. However I have noticed an unusual behaviour in that the script seems to be executed twice. This is not a big problem as such, since it just downloads the files twice. But is this a bug?
For reference, I am connecting to a remote site on port 990, over SSL/TLS, and with SSL Session Reuse ticked.
My command,
corecmd.exe -site MY_SITE -s -scal myscriptfile.txt -log mylog.log
My script file,
CWD /<remotefolder>/
RETR <file1>
RETR <file2>
The resulting log,
02/14/14 12:22 (1792)
Resolving <remotesite>...
Connect socket #504 to <remoteip>, port 990...220 WFTPD 3.1 service (by Texas Imperial Software) ready for new user
AUTH TLS
234 AUTH TLS successful
TLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bitUSER <username>
331 Password required for <username>
PASS **********
230 User <username> logged in
SYST
215 UNIX Type: L8
CWD /<remotefolder>/
250 CWD command successful
Unknown errorPBSZ 0
200 PBSZ 0 successful
PROT P
200 Protection set to Private
PASV
227 Entering Passive Mode (XX,XXX,XX,XX,84,36).
RETR <file1>
150 Opening ASCII mode data connection for <file1> (4309 bytes)
226 Transfer complete
PASV
227 Entering Passive Mode (XX,XXX,XX,XX,83,219).
RETR <file2>
150 Opening ASCII mode data connection for <file2> (1583 bytes)
226 Transfer complete
PASV
227 Entering Passive Mode (XX,XXX,XX,XX,85,22).
LIST
Connect socket #544 to <remoteip>, port 21782...TLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bitTLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bit150 Opening ASCII mode data connection for file list
226 Transfer complete
CWD /<remotefolder>/
250 CWD command successful
Unknown errorPASV
227 Entering Passive Mode (XX,XXX,XX,XX,82,37).
RETR <file1>
Connect socket #532 to <remoteip>, port 21029...TLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bitTLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bit150 Opening ASCII mode data connection for <file1> (4309 bytes)
226 Transfer complete
PASV
227 Entering Passive Mode (XX,XXX,XX,XX,83,64).
RETR <file2>
Connect socket #544 to <remoteip>, port 21312...TLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bitTLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bit150 Opening ASCII mode data connection for <file2> (1583 bytes)
226 Transfer complete
sent 56, recd 56
Total uploaded files: 0
Total uploaded data: 0
Total downloaded files: 0
Total downloaded data: 0
If I put a QUIT at the end of the script, it still appears to try to run it twice but produces the following messages,
QUIT
221 Goodbye.
Unknown errorPASV
2CWD /<remotefolder>/
2PASV
2PORT command failedPASV
2PORT command failedQUIT
2sent 44, recd 44
Total uploaded files: 0
Total uploaded data: 0
Total downloaded files: 0
Total downloaded data: 0
The script is working. However I have noticed an unusual behaviour in that the script seems to be executed twice. This is not a big problem as such, since it just downloads the files twice. But is this a bug?
For reference, I am connecting to a remote site on port 990, over SSL/TLS, and with SSL Session Reuse ticked.
My command,
corecmd.exe -site MY_SITE -s -scal myscriptfile.txt -log mylog.log
My script file,
CWD /<remotefolder>/
RETR <file1>
RETR <file2>
The resulting log,
02/14/14 12:22 (1792)
Resolving <remotesite>...
Connect socket #504 to <remoteip>, port 990...220 WFTPD 3.1 service (by Texas Imperial Software) ready for new user
AUTH TLS
234 AUTH TLS successful
TLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bitUSER <username>
331 Password required for <username>
PASS **********
230 User <username> logged in
SYST
215 UNIX Type: L8
CWD /<remotefolder>/
250 CWD command successful
Unknown errorPBSZ 0
200 PBSZ 0 successful
PROT P
200 Protection set to Private
PASV
227 Entering Passive Mode (XX,XXX,XX,XX,84,36).
RETR <file1>
150 Opening ASCII mode data connection for <file1> (4309 bytes)
226 Transfer complete
PASV
227 Entering Passive Mode (XX,XXX,XX,XX,83,219).
RETR <file2>
150 Opening ASCII mode data connection for <file2> (1583 bytes)
226 Transfer complete
PASV
227 Entering Passive Mode (XX,XXX,XX,XX,85,22).
LIST
Connect socket #544 to <remoteip>, port 21782...TLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bitTLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bit150 Opening ASCII mode data connection for file list
226 Transfer complete
CWD /<remotefolder>/
250 CWD command successful
Unknown errorPASV
227 Entering Passive Mode (XX,XXX,XX,XX,82,37).
RETR <file1>
Connect socket #532 to <remoteip>, port 21029...TLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bitTLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bit150 Opening ASCII mode data connection for <file1> (4309 bytes)
226 Transfer complete
PASV
227 Entering Passive Mode (XX,XXX,XX,XX,83,64).
RETR <file2>
Connect socket #544 to <remoteip>, port 21312...TLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bitTLSv1, cipher TLSv1/SSLv3 (DHE-RSA-AES256-SHA) - 256 bit150 Opening ASCII mode data connection for <file2> (1583 bytes)
226 Transfer complete
sent 56, recd 56
Total uploaded files: 0
Total uploaded data: 0
Total downloaded files: 0
Total downloaded data: 0
If I put a QUIT at the end of the script, it still appears to try to run it twice but produces the following messages,
QUIT
221 Goodbye.
Unknown errorPASV
2CWD /<remotefolder>/
2PASV
2PORT command failedPASV
2PORT command failedQUIT
2sent 44, recd 44
Total uploaded files: 0
Total uploaded data: 0
Total downloaded files: 0
Total downloaded data: 0
-
- Site Admin
- Posts: 1004
- Joined: Mon Mar 24, 2003 4:37 am
-
- Site Admin
- Posts: 1004
- Joined: Mon Mar 24, 2003 4:37 am