Fetch Files from internet

wazza

Registered User.
Local time
Today, 11:55
Joined
Apr 23, 2004
Messages
104
Hi

i got help with fetching files from the internet in the past - only just got round to trying it out - see code below

this openIPnr - what is it and how do i use the syntax.. im searching the help files but cnt find anything

have u got example code so i can use the syntax..
many thanks


solution provided:
___________________________________________________
I create a text file like so:
open IPnr
UserName
Password
cd SomeFolder \ SomeOther \ Folder
get download-00902.txt
get download-00903.txt
bye
Save it somewhere, e.g. C:\ and name it ftpScript.txt

Then do a shell:
Shell ("ftp -s:C:\ftpscript.txt")
 
I think that's a variable.. when you use FTP via command line you normally do it like

OPEN FTP.DOMAIN.COM

username:
password:
etc etc...

so it looks to me like IPnr is your variable to hold the FTP domain information.
 
so for example:

webAd = http://download/file
username = hello
password = enter

would i simply write:

open webAd
username
password

wot syntax is involved - is that it?? (just type username, password - dont i assign it or use some type of argument)
 
I think you got the advise from me didnt you?

No you dont assign it... you just write it in a text file...

Except you wouldnt even declare any variables, just do it....

Try writing a file first by hand or doing it by hand.
Start=> Run
command
Ftp
etc....

see what happenes

Greetz
 
sorry.. this is all very new to me

i can use vb from access to run this text file i create...?

what commands does this text file use? are these some sort of commands that control windows? how would i run this file from vb?

an example would be much appreciated... im going round in circles at the moment!

Thanks very much for all ur help!
 
ok im getting there.....

runs over dos using text file.. not sure how to run this from vb

also

how do i get the IP address of the file destination....??
 
Below sample puts a file (sends to an FTP)
Code:
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub myFtp(myDir As String, myFile As String)
    
    Dim myline As String
        
    If Dir("E:\tempscript.txt") <> "" Then Kill ("E:\tempscript.txt")
    Open "E:\tempscript.txt" For Output As #1
    
    myline = "open IPnr" & Chr(13) & Chr(10) _
    & "HardCode UserName Here" & Chr(13) & Chr(10) _
    & "HardCode PassWord Here" & Chr(13) & Chr(10) _
    & "cd Folder\AnyFolder\SomeFolder\Some full path" & Chr(13) & Chr(10) _
    & "put " & myDir & myFile & Chr(13) & Chr(10) _
    & "bye" & Chr(13) & Chr(10)
    
    Print #1, myline
    
    Close #1
    Shell "command.com /c ftp -s:E:\tempscript.txt"
    Do While Dir("E:\tempscript.txt") <> ""
        Sleep 1000
        On Error Resume Next
        Kill ("E:\tempscript.txt")
    Loop
    On Error GoTo 0
End Sub

Below is a get script (download from FTP) I create this once, and HIDE it (attrib +h) because i need it untill later. Since you need to have the Password in plain text i dont want anybody to just find it.... My app knows where it is anyway.
Code:
Sub CreateGetFTP(ChanginPart As String)
    Dim fso As New Scripting.FileSystemObject
    Dim myline As String
    Shell "Attrib -H E:\FTPScript.txt", vbHide
    Sleep 1000
    On Error Resume Next
    Kill "E:\FTPScript.txt"
    On Error GoTo 0
    myline = "open IPnr" & Chr(13) & Chr(10) _
    & "HardCode UserName Here" & Chr(13) & Chr(10) _
    & "HardCode PassWord Here" & Chr(13) & Chr(10) _
    & "cd Folder\AnyFolder\SomeFolder\Some full path" & Chr(13) & Chr(10) _
    & "get FixedFilePart_" & ChanginPart & ".txt" & Chr(13) & Chr(10) _
    & "get FixedFilePart2_" & ChanginPart & ".txt" & Chr(13) & Chr(10) _
    & "get FixedFilePart3_" & ChanginPart & ".xls" & Chr(13) & Chr(10) _
    & "bye" & Chr(13) & Chr(10)
    Close
    Open "E:\FTPScript.txt" For Output As #1
    Print #1, myline
    Close #1
    Sleep 1000
    Shell "Attrib +H P:\FTPScript.txt", vbHide
End Sub


You can run the scripts using the
Shell "command.com /c ftp -s:E:\tempscript.txt"
Or simply use the ftp -s:.... in a batch file...

I hope this all is clear enough...

Regardz
 
thats great... the example makes it a lot clearer, i will give this ago..

im still not sure about the IP thought, do i need to find out the IP of the server or can i use the website address??
 
I think you can use either....

Greetz
 

Users who are viewing this thread

Back
Top Bottom