Script

FTP

The professional tool to automate FTP, SFTP, FTPS

and schedule FTP batch jobs

MENU MENU
Post a message here if you find anything wrong in ScriptFTP.
Hi Support-Team,

I want to download a bunch of files from a first ftp-server, then do some renaming and afterwards upload the files to a second ftp-server. I use wildcards in the GETFILE command pointed to the first ftp-server and also use wildcards in the PUTFILE command pointed to the second ftp-server.

The first ftp-server allows the MLSD command set, the second do not understand FEAT at all.
As i understand from verbose log, Script-FTP unitlizes the MLSD command when i use wildcards in GETFILE or PUTFILE. When i first open a rich-featured FTP-server ScriptFTP checks via the FEAT command if MLSD can be used and stores this information internally. Later on it uses MLSD if the remote server supports it.

Unfortunately the information 'MLSD can be used' is not resetted when connecting to another FTP-Server. When this server does not support even the FEAT command, ScriptFtp still uses MLSD also on this server. And then the whole transfer fails.

Btw: Doing it the other way round - first connect to a non-MLSD-server, doing some wildcard operations, and then connect to a MLSD-server, everything works fine! But this is not what i wanna to do ;-)

For detailed analysis here my verbose log of a failed session:
SETTYPE(ASCII)
Setting file transfer type to ASCII.

OPENHOST("92.67.98.99","*****",*****)
Connecting to 92.67.98.99
Resolving host name "92.67.98.99"
Connecting to 92.67.98.99 Port: 21
Connected to 92.67.98.99.
220 Welkom
USER *****
331 Password required for *****
PASS *****
230 Logged on
SYST
215 UNIX emulated by FileZilla
FEAT
211-Features:
 MDTM
 REST STREAM
 SIZE
 MLST type*;size*;modify*;
211 End
PWD
257 "/" is current directory.
Connected.

LOCALCHDIR("C:\CASSTAT\Wave\Orders")
Changing current local directory to C:\CASSTAT\Wave\Orders

CHDIR("/uit")
Changing current remote directory to /uit
CWD /uit
250 CWD successful. "/uit" is current directory.
PWD
257 "/uit" is current directory.

GETFILE("B*")
TYPE A
200 Type set to A
PASV
227 Entering Passive Mode (92,67,98,99,99,56)
Opening data connection to 92.67.98.99 Port: 25400
MLSD
150 Connection accepted
0 bytes transferred. (0 Byte/s) (31 ms)
226 Transfer OK
CWD /uit
250 CWD successful. "/uit" is current directory.
PWD
257 "/uit" is current directory.

DELETEFILE("B*")
PASV
227 Entering Passive Mode (92,67,98,99,99,58)
Opening data connection to 92.67.98.99 Port: 25402
MLSD
150 Connection accepted
0 bytes transferred. (0 Byte/s) (47 ms)
226 Transfer OK
No remote file matches the wildcard.
CWD /uit
250 CWD successful. "/uit" is current directory.
PWD
257 "/uit" is current directory.

CLOSEHOST
QUIT
221 Goodbye
Client closed the connection.
Disconnected.

LOCALCHDIR("C:\CASSTAT\Wave")
Changing current local directory to C:\CASSTAT\Wave

EXEC("COPY /Y Orders\B* Orders.bak")
Orders\B*
Das System kann die angegebene Datei nicht finden.
0 Datei(en) kopiert.

LOCALCHDIR("C:\CASSTAT\Wave\Orders")
Changing current local directory to C:\CASSTAT\Wave\Orders

GETLIST(LOCAL_FILES,"B*")
Getting file listing of current local directory

OPENHOST("sd11c","******",******)
Connecting to sd11c
Resolving host name "sd11c"
Connecting to 139.3.211.9 Port: 21
Connected to sd11c.de.henkelgroup.net.
220 sd11c FTP server (Revision 1.1 Version wuftpd-2.6.1(PHNE_34698) Fri Nov 10 10:21:03 GMT 2006) ready.
USER ******
331 Password required for *****.
PASS *****
230-No directory! Logging in with home=/
230 User ***** logged in.
SYST
215 UNIX Type: L8
FEAT
500 'FEAT': command not understood.
PWD
257 "/" is current directory.
Connected.

LOCALCHDIR("C:\CASSTAT\Wave\Orders")
Changing current local directory to C:\CASSTAT\Wave\Orders

CHDIR("/usr/sap/ex/prod/P11/skp/zos")
Changing current remote directory to /usr/sap/ex/prod/P11/skp/zos
CWD /usr/sap/ex/prod/P11/skp/zos
250 CWD command successful.
PWD
257 "/usr/sap/ex/prod/P11/skp/zos" is current directory.

PUTFILE("orders_wave_*")
TYPE A
200 Type set to A.
PASV
227 Entering Passive Mode (139,3,211,9,167,178)
Opening data connection to 139.3.211.9 Port: 42930
MLSD
500 'MLSD': command not understood.
***** PUTFILE Error #500: Cannot read file listing of /usr/sap/ex/prod/P11/skp/zos.
***** The server said: 'MLSD': command not understood.
CWD /usr/sap/ex/prod/P11/skp/zos
250 CWD command successful.
PWD
257 "/usr/sap/ex/prod/P11/skp/zos" is current directory.

DELETEFILE("orders_wave_*")
PASV
227 Entering Passive Mode (139,3,211,9,64,159)
Opening data connection to 139.3.211.9 Port: 16543
MLSD
500 'MLSD': command not understood.
***** DELETEFILE Error #500: Cannot read remote file listing of /usr/sap/ex/prod/P11/skp/zos.
***** The server said: 'MLSD': command not understood.

CLOSEHOST
QUIT
221-You have transferred 0 bytes in 0 files.
221-Total traffic for this session was 859 bytes in 0 transfers.
221-Thank you for using the FTP service on sd11c.de.henkelgroup.net.
221 Goodbye.
Server closed connection
Disconnected.
Regards Christian
Hi Christian,

What version and build of ScriptFTP are you using? (check help->about)

There was a similar bug a while ago that was already fixed. May be updating your ScriptFTP is all you need.
I use ScriptFTP 3.1 Build Oct 9 2008 as ScriptFTP_console.

Now i installed the brand new ScriptFtp 3.2 but the error remains (in the GUI and in the console app). In addition ScriptFTP_console reports still version 3.1.


Regards Christian
Hi Christian,

Download and install ScriptFTP again from here:

http://www.ScriptFTP.com/ScriptFTP_devel_setup.exe

I've added an additional check in OPENHOST and now, in the second server LIST should be used instead of MLST.

Please, let me know if it finally worked or not. I have no way to check this for myself. If it does not work, send me an email with a temporary account in the FTP server for testing (only if it's possible...).
Hi,

you're on a good way bot not on finish yet ;-)

PUTFILE works now, but (in case of an error-free PUTFILE) the script uses also CHMOD which still fails.

I could give you access to the first server (with MLSD feature) but not to the second as this is behind a strong firewall. I couldn't open the firewall for this server as this has to be highly secured. So we need to solve this in teamwork ;-)


Here's the script
FTP Script
  1. $RootDir    = LOCALCWDIR()
  2. $Object     = "Orders"
  3.  
  4. $SrcHost    = "92.67.98.99"
  5. $SrcUser    = "******"
  6. $SrcPw      = "******"
  7. $SrcDir     = "uit"
  8. $SrcPrefix  = "B"
  9. $SrcDiv     = ""
  10. $SrcList    = ""
  11. $SrcFile    = ""
  12.  
  13. $DestHost   = "sd11c"
  14. $DestUser   = "******"
  15. $DestPw     = "******"
  16. $DestDir    = "/usr/sap/ex/prod/P11/skp/zos"
  17. $DestPrefix = "orders_wave_"
  18. $DestDiv    = "_"
  19. $DestFile   = ""
  20.  
  21. #########################################################################
  22.  
  23. VERBOSE(ON)
  24.  
  25. LOGTO($RootDir."\LOG\".GETDATE(YEAR)."-".GETDATE(MONTH).".log",APPEND)
  26. PRINT("")
  27. PRINT("")
  28. PRINT("*** ".GETDATE(FORMAT2)." *** ".GETPARAM(2)." *****************************")
  29.  
  30. SETTYPE(ASCII)
  31.  
  32. $I=1
  33. WHILE(OPENHOST($SrcHost,$SrcUser,$SrcPw) != "OK")
  34.   IF($I == 5)
  35.     EXIT(1)
  36.   END IF
  37.   $I=$I+1
  38.   SLEEP(10)
  39.  
  40. LOCALCHDIR($RootDir."\".$Object)
  41. CHDIR("/".$SrcDir)
  42. IF(GETFILE($SrcPrefix."*") != "OK")
  43.   EXEC("del /Q ".$SrcPrefix."*")
  44.   EXIT(2)
  45.   DELETEFILE($SrcPrefix."*")
  46.  
  47.  
  48. #########################################################################
  49.  
  50. LOCALCHDIR($RootDir)
  51. EXEC("COPY /Y ".$Object."\".$SrcPrefix."* ".$Object.".bak")
  52.  
  53. LOCALCHDIR($RootDir."\".$Object)
  54. GETLIST($SrcList, LOCAL_FILES, $SrcPrefix."*")
  55. FOREACH $SrcFile IN $SrcList
  56.   $DestFile = $DestPrefix.TEXTCUT($SrcFile, TEXTLENGTH($SrcPrefix) + 1, 8).$DestDiv.TEXTCUT($SrcFile, TEXTLENGTH($SrcPrefix) + 8 + TEXTLENGTH($SrcDiv) + 1, 6)
  57.   EXEC("RENAME ".$SrcFile." ".$DestFile)
  58.  
  59. #########################################################################
  60.  
  61. $I=1
  62. WHILE(OPENHOST($DestHost,$DestUser,$DestPw) != "OK")
  63.   IF($I == 5)
  64.     EXIT(1)
  65.   END IF
  66.   $I=$I + 1
  67.   SLEEP(10)
  68.  
  69. LOCALCHDIR($RootDir."\".$Object)
  70. CHDIR($DestDir)
  71.  
  72. IF(PUTFILE($DestPrefix."*") != "OK")
  73.   DELETEFILE($DestPrefix."*")
  74.   EXIT(2)
  75.   CHMOD(777,$DestPrefix."*")
  76.   EXEC("del /Q ".$DestPrefix."*")
  77.  
  78.  
...and the current logfile:

SETTYPE(ASCII)
Setting file transfer type to ASCII.

OPENHOST("92.67.98.99","******",******)
Connecting to 92.67.98.99
Resolving host name "92.67.98.99"
Connecting to 92.67.98.99 Port: 21
Connected to 92.67.98.99.
220 Welkom
USER ******
331 Password required for ******
PASS ******
230 Logged on
SYST
215 UNIX emulated by FileZilla
FEAT
211-Features:
 MDTM
 REST STREAM
 SIZE
 MLST type*;size*;modify*;
211 End
PWD
257 "/" is current directory.
Connected.

LOCALCHDIR("C:\CASSTAT\Wave\Orders")
Changing current local directory to C:\CASSTAT\Wave\Orders

CHDIR("/uit")
Changing current remote directory to /uit
CWD /uit
250 CWD successful. "/uit" is current directory.
PWD
257 "/uit" is current directory.

GETFILE("B*")
TYPE A
200 Type set to A
PASV
227 Entering Passive Mode (92,67,98,99,135,18)
Opening data connection to 92.67.98.99 Port: 34578
MLSD
150 Connection accepted
0 bytes transferred. (0 Byte/s) (32 ms)
226 Transfer OK
CWD /uit
250 CWD successful. "/uit" is current directory.
PWD
257 "/uit" is current directory.

DELETEFILE("B*")
PASV
227 Entering Passive Mode (92,67,98,99,135,20)
Opening data connection to 92.67.98.99 Port: 34580
MLSD
150 Connection accepted
0 bytes transferred. (0 Byte/s) (47 ms)
226 Transfer OK
No remote file matches the wildcard.
CWD /uit
250 CWD successful. "/uit" is current directory.
PWD
257 "/uit" is current directory.

CLOSEHOST
QUIT
221 Goodbye
Server closed connection
Disconnected.

LOCALCHDIR("C:\CASSTAT\Wave")
Changing current local directory to C:\CASSTAT\Wave

EXEC("COPY /Y Orders\B* Orders.bak")
Orders\B*
Das System kann die angegebene Datei nicht finden.
0 Datei(en) kopiert.

LOCALCHDIR("C:\CASSTAT\Wave\Orders")
Changing current local directory to C:\CASSTAT\Wave\Orders

GETLIST(LOCAL_FILES,"B*")
Getting file listing of current local directory

OPENHOST("sd11c","******",******)
Connecting to sd11c
Resolving host name "sd11c"
Connecting to 139.3.98.99 Port: 21
Connected to sd11c
220 sd11c FTP server (Revision 1.1 Version wuftpd-2.6.1(PHNE_34698) Fri Nov 10 10:21:03 GMT 2006) ready.
USER ******
331 Password required for ******.
PASS ******
230-No directory! Logging in with home=/
230 User ****** logged in.
SYST
215 UNIX Type: L8
FEAT
500 'FEAT': command not understood.
PWD
257 "/" is current directory.
Connected.

LOCALCHDIR("C:\CASSTAT\Wave\Orders")
Changing current local directory to C:\CASSTAT\Wave\Orders

CHDIR("/usr/sap/ex/prod/P11/skp/zos")
Changing current remote directory to /usr/sap/ex/prod/P11/skp/zos
CWD /usr/sap/ex/prod/P11/skp/zos
250 CWD command successful.
PWD
257 "/usr/sap/ex/prod/P11/skp/zos" is current directory.

PUTFILE("orders_wave_*")
CWD /usr/sap/ex/prod/P11/skp/zos
250 CWD command successful.
PWD
257 "/usr/sap/ex/prod/P11/skp/zos" is current directory.

CHMOD("777","orders_wave_*")
TYPE A
200 Type set to A.
PASV
227 Entering Passive Mode (139,3,211,9,85,116)
Opening data connection to 139.3.211.9 Port: 21876
MLSD
500 'MLSD': command not understood.
***** CHMOD Error #500: Cannot read file listing of /usr/sap/ex/prod/P11/skp/zos.
***** The server said: 'MLSD': command not understood.

EXEC("del /Q orders_wave_*")
C:\CASSTAT\Wave\Orders\orders_wave_* konnte nicht gefunden werden

CLOSEHOST
QUIT
221-You have transferred 0 bytes in 0 files.
221-Total traffic for this session was 765 bytes in 0 transfers.
221-Thank you for using the FTP service on sd11c.
221 Goodbye.
Server closed connection
Disconnected.
Ok, no problem. :) I've done some modifications again. Now the output should show what's happening there. Download and install ScriptFTP again from here:

http://www.ScriptFTP.com/files/ScriptFTP_devel_setup.exe
Hi!

Now it works... thx for quick response and a great tool!!!!

Best Regards,

Christian
Great :)