Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Download single file fro ftp folder 3

Status
Not open for further replies.

keepingbusy

Programmer
Apr 9, 2000
1,470
GB
Hello

I found the FAQ faq184-3234 I have tried the coding for "*... FTPGet.PRG ...*"

Part of that is:

Code:
DO ftpget WITH 'ftp.host', 'name', 'password', 'source.file', 'target.file'[, 1 | 2]

I have tried using:

Code:
DO ftpget WITH 'ftp://ftp.xxxxx.xxx/our_report', 'ourusername', 'ourpassword', 'ourfile.txt', '\savedfiles'

I have also tried using:

Code:
DO ftpget WITH 'ftp.xxxxx.xxx/our_report', 'ourusername', 'ourpassword', 'ourfile.txt', '\savedfiles'

I know the target address exists because we access this manually by typing in ftp://ftp.xxxxx.xxx/our_report in the address bar, then enter our user name and password.

Any suggestions please why I am receiving the message (as per the FAQ code):

Unable to connect to ftp.xxxxx.xxx/our_report

Many thanks
 
FTP host is just the host name, not a dir. You must do it as it is defined.

Path should be part of the source.file name.

So

Do ftpget WITH 'ftp.host.tld', 'ourusername', 'ourpassword', 'our_report/ourfile.txt' , 'd:\store\it\here\ourfile.txt`'

Please remember in URLs and internet adresses pathing is done with slash, not backslash.
The last parameter can't just have a relative path, you'e using Windows API and Windows has no idea of the current directorty or working directorty of your foxpro app.

Why don't you use any other of the available FTP solutions, that work even easier?
See here: thread184-1697949

Bye, Olaf.
 
For example with vfpconnection.fll you only write

SET LIBRARY TO c:\some\path\to\vfpconnection.fll && only needed once in main.prg for all usages of all FTP(S) and HTTP(S) commands included in the FLL.
FTPGet("FTP://UserName:password@somedomain.com/directory/Source.zip", "C:\Destination.zip")

And that's it.

In this case you really can use the ftp address as you're knowing it 1:1 with password and username included.

Bye, Olaf.
 
One thing I see is that the parameters you pass don't match the pattern:
*: Usage: DO ftpget WITH ;
*: 'ftp.host', 'name', 'password', 'source.file', 'target.file'[, 1 | 2]
*:
*: Where: lcHost = Host computer IP address or name
*: lcUser = user name - anonymous may be used
*: lcPwd = password
*: lcRemoteFile = source file name
*: lcNewFile = target file name
*: lnXFerType = 1 (default) for ascii, 2 for binary


But you are trying to use:
DO ftpget WITH;
'ftp://ftp.xxxxx.xxx/our_report',;
'ourusername',;
'ourpassword',;
'ourfile.txt',;
'\savedfiles'


Where is your IP Address for the lcHost?
Where in the original Parameter string does it show SavedPath?

While I don't have a specific answer for you, I'd suggest that you limit the first parameter to ONLY the IP address (or DNS name) - NOT a URL
Then put the Target path with the Remote File parameter.
Put the Destination path with the New File parameter - not into a separate parameter.
Finally, ask the originator what file type they have to pick up - Binary or ASCII - set the last parameter accordingly.

In order to test you could run just the FUNCTION connect2ftp portion of the code to ensure that the IP, Username, & Password were in the proper format and being handled correctly.

Good Luck,
JRB-Bldr
 
>Where is your IP Address for the lcHost?

It doesn't need to be IP, it says "OR name". So it can be "ftp.host" as in the first try, but if "source.file" is not in the root directory this call doesn't work. When you connect to an FTP server you connect to a root dir. Either you send FTP commands to a connection, navigating to sub directories, or you specify the path in the source file parameter.

...I think other implementations are much easier to use... see my post about vfpconnection.

Bye, Olaf.
 
JRB-Bldr & Olaf

Thanks for your posts guys.

I did originally post this question in the Windows 7 forum thinking it was a DOS related question. I will look at the suggestions you have posted and get back when I find a sollution.

My biggest problem at the moment I just cannot seem to get past the first hurdle of making a connection even though I can see the .txt file when I type in the FTP url address in a browser.

Just to add a bit more, the whole purpose of this set up is for me to put together a piece of code that will run on the hour either using a timer within VFP (9) or use Windows Scheduler to run a compiled exe file. What we need this for is to download a file every hour with an update to list.

Post back soon

Thanks again.
 
It doesn't need to be IP, it says "OR name"

I only know that I use the FTPPut part of the same code group and I use the IP address of the FTP server (or DNS name) - the same as I have to use when I initially set up the Host definition in an interactive FTP client like WS_FTP.

keepingbusy - Good Luck,
JRB-Bldr



 
>I did originally post this question in the Windows 7 forum thinking it was a DOS related question.

Well, if you look at the code and not just run it, you see it makes DECLAREs in wininet.dll, so no, it's not DOS related. This DLL exists since perhaps XP.

FTPGet does connect vie the line
hftpSession = InternetConnect (hOpen, lcHost, 0, lcUser, lcPwd, 1, 0, 0)

In this your lcHost has to be correct, and you didn't specify it correctly, as both me and jrbblr already said. You can make use of this code, you just have to specify the parameters correctly. The host has to be the host, just the host and only the host. No ftp://, that's part of an URL specifying the protocol, the host name can start with ftp. or - as jrbbldr uses it, can be an IP adddess, but it does never start with ftp://, also the host name ends at .com or whatever other top level domain, or in case of an IP with the 4th number of the ip address. Directories and slash or backslash are not part of the host name.

Read, Lee, just read.

Bye, Olaf.
 
Olaf

I did originally post this question in the Windows 7 forum thinking it was a DOS related question.

If you took the time to read this correctly and get an understanding of what I posted, the reason I asked this question in the Windows 7 forum first was because I thought I could achieve this by using DOS commands BEFORE I asked the question in this forum.

When I did some research within this forum, I came across the FAQ, hence the reason I asked the question here. I would much prefer to use VFP9 to develop a working application than some old .bat file.

I'm not sure why, but the last few times I have posted questions in this forum you have come across as very negative towards me, something which in the past you have agreed.

I don't know you (other than from your recognised expertise over the years I have watched this forum) and you don't know me and my understanding of this very useful website is to ask for help and guidance and not necessarily the answer which is something I am more than happy to learn from.

In view if this, I have no further desire to post any questions in fear of the negative responses from some individuals.

My advice to you my friend is to "Read, Olaf, just read." and don't assume everyone else has the experience you do.

I would like to say my sincerest thanks to all those who kindly assisted me in the past and I wish you well.

Lee
 
In view if this, I have no further desire to post any questions in fear of the negative responses from some individuals.

Lee, I know you wouldn't make a statement like that lightly. Nevertheless, I wish you would reconsider. You are one of the few people here who can be relied on to post sensible, relevant questions, with all the facts clearly stated - unlike so many others, whose questions are vague and muddled, and where we need to post several follow-up questions just to establish the facts.

I can't comment on the negative responses you've been getting, but please weigh those against what I hope are the positive benefits you gain from being a member of this community.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Mike

Like others, you are one of the many who have greatly assisted me in the past for which I'm grateful but like anything in life, there does come a point when you have to ask yourself the question which I have already answered.

I would like to think I am a very positive person and I'm no whipper snapper, if you get where I'm coming from.

I appreciate your post and comments but I have decided to call it a day with this forum.

Thank you Mike and I wish you well.

Lee
 
Fair enough Lee,

I can offer you to leave you leave you alone and ignore your questions in the future, so you still can take advantage of the help of others here.

What's correct is, it is my decision to help or not and instead of getting heated about the obvious mistakes I see in your failed attempt code, I could also let more positive feelings win, like compassion and sympathy. And I have sympathy for you, otherwise I would not answer the question.

Sorry, but in review of what was said as excuses and what still happens with me, this may be the better offer for you than to decline asking questions here.

And this is also a truth - it happens to me, not by your fault, not by mine. It is me, but I obviously fail to ignore and suppress my urge to complain about such misunderstandings. This also is feeling embarrassment for you, when you fail to see something obvious. Well, you're right, it's obvious to me in that case, but not to everyone.

What do you think about that?

Bye, Olaf.
 

May be you could:

* go dos prompt - interactive mode and type the following
ftp ftp.domainname.com
user username@domainname.com password
dir
binary
get yourfilename1.txt
get filename1.txt c:/mydownloads/filename1.txt
quit

* Verify if you have retrieved the file on your local drive.
* Observe the UPPER/lower case in the file name
* use cd command to switch to sub dir if required
* if username@domainname.com does not work then try without @domainname.com.
* if all works then create your vfp program with the timer and
* a) create batch file in your vfp by using strtofile(), text ... endtext, etc.
* b) shellexecute() at speciefied intervals
* c) delete this batch. remember - your username password is visible in the batch file.
* i personally use ifox.ftp ( search on this form and on google, you will get lots of information.)

* hope this will help

 
Olaf is quite correct in the advice he has offered you but perhaps the wording of his reply could have been a little less confrontational.
In my uderstanding, I believe the host cannot be ftp.mysite.com, it is more likely to be or some variant of it.
I have used this script several times but alwys with the IP address which is a lot less variable in it's format.

Keith
 
Hello Keith,

I received your notification via email and would not wish to ignore you.

If you take a look at I have found some coding I now use in a batch file as described in the thread and together with the VFP RUN command I have now been able to fully automate and accomplish what I set out to do.

I'm grateful for your post and words.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top