PDA

View Full Version : Need a little FTP Plugin help


Animl
10-04-2006, 08:25 PM
I'm having some error problems on something that looks easy, but obviously I'm not catching it. I used the FTP Plugin example from the help page and trying to download a text file from the the NWS ftp server. I can get the file real easy using a browser. But for some reason using HTTP or FTP don't seem to work for me. I assume I should be using the FTP plugin to get a file from an ftp?

The code I am trying should be below,..


-- step 1: connect anonymously to cdrom.com
FTP.Connect("ftp.tgftp.nws.noaa.gov");
err = Application.GetLastError();
if err ~= FTP.OK then
Dialog.Message("Error", _tblErrorMessages[err]);
end

-- step 2: change to the directory where the text file is located
FTP.ChangeDir("/data/forecasts/zone/in");
err = Application.GetLastError();
if err ~= FTP.OK then
Dialog.Message("Error", _tblErrorMessages[err]);
end

-- step 3a: enable the status dialog's cancel button
StatusDlg.ShowCancelButton();

-- step 3b: show the status dialog
StatusDlg.Show();

-- step 3c: download the file as <temp>\Hamlet.txt
FTP.Download("inz001.txt", "\\AutoPlay\\Docs\\alerts\\inz001.txt");
err = Application.GetLastError();

-- step 3d: hide the status dialog
StatusDlg.Hide();

-- step 4: log off
FTP.Disconnect();

-- ...now check whether FTP.Download generated an error
if err == FTP.OK then
Dialog.Message("Success!", " was downloaded successfully!");
else
Dialog.Message("Error", _tblErrorMessages[err]);
end

Intrigued
10-04-2006, 09:01 PM
Without looking to close at your code (off to bed time for me), check out:
FTP.SetTransferType(FTP.BINARY)

See if that works for you.

Animl
10-04-2006, 09:18 PM
Thanks,
I'm still getting a "No Response From Server".
What ever that is I'm sure would clear up problem #2 "Request to set data port rejected (Port command failed)". Probably should have posted that.

Intrigued
10-04-2006, 09:23 PM
Hang in there... we have some overseas folks and some late night coders coming on that will surely help you out. If not, tomorrow I'll work with you on it.

(come on late night coders!)

:lol

Lorne
10-05-2006, 08:50 AM
Well for starters, the address isn't:

ftp.tgftp.nws.noaa.gov

...it's:

tgftp.nws.noaa.gov

Also make sure you set the download path to a valid folder, or you'll get an "Unknown error" message. For example, I had to change this line:

FTP.Download("inz001.txt", "\\AutoPlay\\Docs\\alerts\\inz001.txt");

...to this:

FTP.Download("inz001.txt", "C:\\temp\\inz001.txt");

...for it to work on my system.

Animl
10-05-2006, 12:27 PM
Figures, ftp.tgftp.nws.noaa.gov is what NWS suggest using. Should have known better then to give gov directions credability. ;-)

Animl
10-05-2006, 02:19 PM
Thanks for the halp Loren.

Also found that this
\\AutoPlay\\Docs\\alerts\\inz001.txt
should have been
AutoPlay\\Docs\\alerts\\inz001.txt

A simple one I would have found once I connected.

All is good.
This is a very productive forum and community.

I know it seems like I have a LOT of mindles problems, but I have 6 projects on the bench each having no less then 2000 lines of coding. I think I just get to deep sometimes and tired and miss the easy stuff. ;-)