| 1. |
Solve : FTP connection? |
|
Answer» Hi all, The files are retrieved with ws-ftp from Jan, I can't log in with those credentials. The connection fails.Hi foxidrive as in the screen print attached from ws-ftp>> gov.jpg you should GET gov-2.jpg default ftp - passive mode with anonymous the password is any e-mail account name (and of course without quotes...;-) [attachment deleted by admin to conserve space]1) So are you saying you want to add an FTP option to your existing batch file? 2) Why are you using a FOR command to rename all the files. Just use the rename command by itself!Answer-1:Yes Answer-2: each file name must have a reference with an UTC hour; these files are refreshed every hour on the server %time% generates single or double digit if it can be done simpler, let me know please. Thanks for your advice JanAnswer 2 does not make any sense to me.These two lines of code and the 22 before it make ABSOLUTELY no logical sense. Code: [Select]FOR %%f IN (23Z.TXT) do rename 23Z.txt 23.txt FOR %%f IN (metar.txt) do del /q c:\fsd\metar.txtYou do not need to use the FOR command to RENAME or DELETE these files! Quote from: klm149 on July 27, 2015, 10:51:29 AM Hi foxidrive It seems to have been a security software on my computer. Quote from: klm149 on July 27, 2015, 02:46:22 PM %time% generates single or double digit yes, you can generate time figures without the leading space. Use this and then reference the %t% variable instead of %time% Code: [Select]set t=%time: =0% Quote from: klm149 on July 27, 2015, 08:12:45 AM I wrote a batch for extracting the correct weather file from a weather server (see attached autometar.bat) Can you explain which weather file you need? Is it just the file from the current hour?the weather file from the current UTC hour e.g. 06Z.TXT is used and copied as metar.txt Windows FTP client can't be used on this server. I've investigated and Windows FTP.EXE can put the server into passive mode, which the tgftp.nws.noaa.gov server requires, but the FTP client itself doesn't work in passive mode (PASV). The FTP.EXE also has trouble with the PORT command, from what I have read. This script shows it connecting and the PASV command implemented, but the permission denied error when attempting to download the file is because the FTP.EXE is not also in passive mode. Code: [Select]echo off set "ftpHost=tgftp.nws.noaa.gov" set "ftpUser=anonymous" set "[email protected]" set "ftpRemoteDir=/data/observations/metar/cycles/" set "ftpLocalDir=%cd%" set t=%time: =0% set t=%t:~0,2% ( echo open %ftpHost% echo %ftpUser% echo %ftpPwd% echo quote pasv echo get %t%Z.TXT echo bye )>"%ftpLocalDir%\temp.ftp" ftp.exe -i -s:"%ftpLocalDir%\temp.ftp" del "%ftpLocalDir%\temp.ftp" pause Thank You! Do you know how to capture 227 Entering Passive Mode (205,156,51,233,128,29) (h1,h2,h3,h3,P1,p2) After setting the remote site to PASV mode the client should give a handshake, returning a port to access. When you add echo type ascii after quote pasv it will return with a port H1./.h4 (is the IPaddress of the server) p1, p2 p1*256+p2 gives the port number to listen on the client hence permission denied when RETR nnZ.txt 227 Entering Passive Mode (205,156,51,233,237,13 ftp> type ascii ---> TYPE A 200 Switching to ASCII mode. ftp> get 16Z.TXT ---> PORT 192,168,1,15,14,219 550 Permission denied. ---> RETR 16Z.TXT 550 Failed to open file. ftp> bye ---> QUIT 221 Goodbye. So far so good Quote from: klm149 on July 28, 2015, 11:05:55 AM hence permission denied when RETR nnZ.txt Did you follow my previous post? FTP.EXE can't use PASV mode and this is causing the error.I think this is the show stopper...thanks for your efforts Jan |
|