|
-
Feb 4th, 2003, 11:05 AM
#1
Thread Starter
Fanatic Member
One File, loads of lines... into a string... how hard could it be?
While one of our servers are offline... it's gives me a chance to upload some files locally.
Here's what we need...
We have a file, which contains litterally thousands of names which we need to upload to the servers VIA FTP. Each name is on a seperate line, IE.
john
craig
bob
I need a package which open's FTP to an IP, and creates separate directories called john, craig & bob respectively.
Anyone with quick idea's???
I need code BTW, i'm not expecting you code the program 
Regards,
Paul.
P.S Brainy buffs v.welcome!
Last edited by VisionIT; Feb 4th, 2003 at 11:38 AM.
-
Feb 4th, 2003, 11:42 AM
#2
Addicted Member
I took this off another thread...
It's actually pretty easy - just use the Inet control. You may have to add the MS Internet Transfer Control 6.0 component to your project first though.
Just put an Inet control on your form, then put this code wherever:
---
With Inet1
.URL = "hostname or IP address"
.UserName = "user name"
.Password = "password"
.Execute , "FTP commands"
Do While .StillExecuting
DoEvents
Loop
End With
---
Your FTP commands statement should look something like this if you want to send a file:
PUT <local path+file> <remote path+file>
You may or may not not need the DoEvents command - just play around with it a bit.
I would guess you would create a loop to read a line from the file, and then issue the FTP command to create a folder using that name.
for example:
VB Code:
intFileNbr=FreeFile
OPEN "names.txt" For Input As #intFileNbr
While Not EOF(intFileNbr)
Line Input #intFileNbr, strName
Inet1.Execute "md " & strName
Wend
Close intFileNbr
Last edited by vfluckey; Feb 4th, 2003 at 11:49 AM.
Hello? Underpaid code monkey speaking...
-
Feb 4th, 2003, 11:44 AM
#3
Thread Starter
Fanatic Member
You lost me where it said Inet!!! 
Anyone care to brief me? Or shoot me... either will do fine ATM.
Regards,
Paul.
-
Feb 4th, 2003, 11:50 AM
#4
Addicted Member
Hello? Underpaid code monkey speaking...
-
Feb 4th, 2003, 11:52 AM
#5
Thread Starter
Fanatic Member
cheers m8y... just reading it now...
You're a damn fast typer 
Regards,
Paul.
-
Feb 4th, 2003, 11:56 AM
#6
Addicted Member
it's untested, but let me know if you get it to work, and post the code if you can, I'd like to see the finished function.
Hello? Underpaid code monkey speaking...
-
Feb 4th, 2003, 12:02 PM
#7
Thread Starter
Fanatic Member
i've tested it... and it doesn't work! 
It says "invalid or unqualified reference on the "URL = " section.
Help! 
Regards,
Paul.
-
Feb 4th, 2003, 12:18 PM
#8
Addicted Member
this is what I would try. I get "file not found" with this exact code
(of course the file is not found!)
VB Code:
Dim intFileNbr As Integer
Dim strName As String
With Inet1
.URL = "hostname or IP address"
.UserName = "user name"
.Password = "password"
intFileNbr = FreeFile
Open "names.txt" For Input As #intFileNbr
While Not EOF(intFileNbr)
Line Input #intFileNbr, strName
.Execute "mkdir " & strName
While .StillExecuting: DoEvents: Wend
Wend
Close intFileNbr
End With
Hello? Underpaid code monkey speaking...
-
Feb 4th, 2003, 12:27 PM
#9
Lively Member
It appears that you need to read some information on this subject... Just so happens that Juicy Studio:
http://www.juicystudio.com/tutorial/vb/http.html
Has a working FTP example.
Its a complete application and you can download the code from there.
Failing that..
http://www.vbip.com/winsock/winsock_ftp_client_01.asp
Has a brilliant example, although it would be more complex to understand the underlying code.
All the best.
Gav
-
Feb 4th, 2003, 12:32 PM
#10
Addicted Member
ok, so I missed a comma... I've never worked w/ the Inet control before, but it looked simple enough
Hello? Underpaid code monkey speaking...
-
Feb 4th, 2003, 12:33 PM
#11
Thread Starter
Fanatic Member
the code works... to an extent...
I get no errors from VB, but the directory never appears???
I'm confused...
Thanks for all your help BTW
Regards,
Paul.
-
Feb 4th, 2003, 12:37 PM
#12
Addicted Member
hmmmm.... I'd guess the error is in the FTP command...
do a debug.print of the ftp command, and then try that string in an ftp session. might have to change directories to put it in the right place...
I dont have an ftp site to test off of, or I'd be more help
Hello? Underpaid code monkey speaking...
-
Feb 4th, 2003, 01:47 PM
#13
Thread Starter
Fanatic Member
Still not working peeps...
Any other ways to connect to an FTP server and carry out the required process?
Cheers
Paul.
-
Feb 4th, 2003, 02:53 PM
#14
Lively Member
Have you looked at the code i told you about? Juicy Studio and VBIP?
This should give you a good grounding.
Gav
-
Feb 4th, 2003, 05:27 PM
#15
Thread Starter
Fanatic Member
I have... and thanx for the details.
Turns-out to be a DNS fault with our ISP's... 
We now have the documents in TCL, and it's worked fine.
Cheers... all.
Regards,
Paul.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|