FTP Help

JMB

Active Member
Licensed User
Longtime User
Hi there. Total Noob question coming up - please don't laugh.

I am trying to retrieve text from an FTP site.

If I enter

ftp://tgftp.nws.noaa.gov/data/forecasts/taf/stations/EGPH.TXT

into my browser I get a file back with the text for EGPH -that's the ICAO code for an airfield, and that FTP call returns the weather for that airfield, EGPH being Edinburgh in the UK.

If I send

ftp://tgftp.nws.noaa.gov/data/forecasts/taf/stations/EGPD.TXT

I get the weather for EGPD - Aberdeen in the UK.

I am sure you get the general idea! :)

My question is how do I replicate this in B4A? The login for the NOAA.GOV site is via anonymous FTP through port 21, so I have been trying to connect and get the weather text using the following code:

the_ftp="ftp://tgftp.nws.noaa.gov"

myFTP.ABFTPConnect(the_ftp,21,"anonymous","")
If myFTP.ABFTPConnected = True Then
Msgbox("Connected", "")
Else
Msgbox(myFTP.ABFTPLastError, "")
Return
End If

This does not work. I just get an "Error connecting" message back.

And as a result, the following code to retrieve the weather and store it locally never gets to run - although I suspect this code is wrong too.

myftp.ABFTPDownload("/data/observations/metar/stations/","EGPD.TXT", sdRoot, "egpf.txt")


Where am I going wrong?

Thanks for any help.

Jonathan
 

JMB

Active Member
Licensed User
Longtime User
Fixed

Hi Erel. Yes, I had tried almost every combination I could think of for the login. I used SmartFTP to watch how it succesfully logged in, and it used "anonymous" as the login.

However, I fixed it as below.

I tried removing the "ftp://" bit from the_FTP string to make the connection string as below:

the_ftp="tgftp.nws.noaa.gov"

That worked!

Sorted. Thank you! :)
 
Upvote 0

marcomilazzo

Member
Licensed User
Longtime User
hi
i'm using the following code

myFTP.ABFTPConnect("79.34.70.18", 21, "marco" ,"delfino")
If myFTP.ABFTPConnected = True Then
Msgbox("Connected", "")
Else
Msgbox(myFTP.ABFTPLastError, "")
Return
End If
many times it doesn't connect at all
some times it works
I have no problem with a normal pc based sw
Any idea?
ciao marco
 
Upvote 0
Top