Re: FTP Upload by McKirahan
McKirahan
Fri Sep 10 10:01:26 CDT 2004
"Nijazi Halimaji" <duda@hotmail.com> wrote in message
news:uM7N96zlEHA.3476@tk2msftngp13.phx.gbl...
> Hi
>
> I have a problem with a script I wrote in VBS. I am trying to upload a
file
> through FTP to a server! I made follwing script but the script always
hung!
> Here is the script:
>
> dim url,rdir,user,pass,fname
> url="ftp://server.ch/"
> rdir=""
> fname="Stelle.xls"
> user="User"
> pass="Pass"
> call Fdf(url,rdir,user,pass,fname)
>
> Sub Fdf(url,rdir,user,pass,fname)
>
> dim fso, ftpo
> Set fso = WScript.CreateObject("Scripting.FileSystemObject")
> Set ftpo = WScript.CreateObject("InetCtls.Inet.1")
> ftpo.URL = url
> ftpo.UserName = user
> ftpo.Password = pass
> ftpo.Execute , "CD " & rdir
>
> Do
> WScript.Sleep 100
> Loop while ftpo.StillExecuting
>
> ftpo.Execute , "Put C:\" & fname& " " & fname
> Do
> WScript.Sleep 100
> Loop while ftpo.StillExecuting
>
> ftpo.Execute , "Close"
> End Sub
>
>
> The script always hung! Can someone help me with ftp-upload? Thanks alot
>
> Nijazi Halimaji
>
How about the following? Watch for word-wrap.
Option Explicit
'*
Const cVBS = "upload.vbs"
Const cFTP = "upload.ftp"
Const cDOM = "ftp://server.ch/"
Const cDIR = ""
Const cFIL = "Stelle.xls"
Const cUSR = "User"
Const cPWD = "Pass"
'*
Dim strOTF
strOTF = "open " & cDOM & vbCrLf
strOTF = strOTF & cUSR & vbCrLf
strOTF = strOTF & cPWD & vbCrLf
strOTF = strOTF & "hash" & vbCrLf
strOTF = strOTF & "binary" & vbCrLf
strOTF = strOTF & "cd " & cDIR & vbCrLf
strOTF = strOTF & "put " & cFIL & vbCrLf
strOTF = strOTF & "close" & vbCrLf
strOTF = strOTF & "bye" & vbCrLf
'*
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objOTF
Set objOTF = objFSO.OpenTextFile(cFTP,2,true)
objOTF.WriteLine(strOTF)
Set objOTF = Nothing
Set objFSO = Nothing
'*
Dim objWSS
Set objWSS = CreateObject("WScript.Shell")
objWSS.Run "%comspec% /k ftp -i -s:" & cFTP,2,True
Set objWSS = Nothing