Anzeige
Archiv - Navigation
284to288
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
284to288
284to288
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

FTP-Upload 1&1

FTP-Upload 1&1
22.07.2003 23:12:08
andre
Hallo allerseits,
bekomme keine daten mit ftp-makro hochgeladen. es wird nur ein dateieintrag gemacht, mit 0 byte. Zusatzfrage: wozu ist das staring nach dem shell "ftp.. gut?
makro:

Private Sub CommandButton1_Click()
Open "c:\login.txt" For Output As #1
Print #1, Worksheets("tabelle1").[b2] 'User
Print #1, UserForm1.TextBox2.Text 'Passwort
Print #1, "cd " & Worksheets("tabelle1").[b3] 'TargetDirectory, z.B. /a-schau/
Print #1, "ascii" '"binary"
Print #1, "put " & Worksheets("tabelle1").[b4] 'UploadFile, z.B. c:\test.txt
Print #1, "bye" '"quit"
Close
Shell "ftp -d -s:c:\login.txt " & _
Worksheets("tabelle1").[b1], vbNormalFocus  'vbHide
staring = "ftp -s:c:\login.txt " & _
Worksheets("tabelle1").[a1]
'wozu ist staring?
'Kill "c:\login.txt"
End Sub

ftp-mitschnitt:
Verbindung mit www.a-schau.de wurde hergestellt
220 FTP Server ready
Benutzer (www.a-schau.de:(none)):
---> USER xxxx-xxx
331 Password required for xxxx-xxx.
---> PASS abcdefgh
230 User xxxx-xxx logged in.
ftp>
ftp> cd /a-schau/
---> CWD /a-schau/
250 CWD command successful
ftp> ascii
---> TYPE A
2ßß Type set to A
ftp> put c:\test.txt
---> PORT 123,456,789,12,1,12 (hier stehn andere nummern)
200 PORT command successful
---> STOR test.txt
hier bleibt’s hängen,
gruss andre

6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: FTP-Upload 1&1
23.07.2003 08:50:16
Michael Scheffler
Hi,
auch hier gilt, dass der einfachste Weg nicht immer der beste ist - so etwas ist immer etwas für API. Ein Code aus dem API-Guide.
Const FTP_TRANSFER_TYPE_UNKNOWN = &H0
Const FTP_TRANSFER_TYPE_ASCII = &H1
Const FTP_TRANSFER_TYPE_BINARY = &H2
Const INTERNET_DEFAULT_FTP_PORT = 21 ' default for FTP servers
Const INTERNET_SERVICE_FTP = 1
Const INTERNET_FLAG_PASSIVE = &H8000000 ' used for FTP connections
Const INTERNET_OPEN_TYPE_PRECONFIG = 0 ' use registry configuration
Const INTERNET_OPEN_TYPE_DIRECT = 1 ' direct to net
Const INTERNET_OPEN_TYPE_PROXY = 3 ' via named proxy
Const INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4 ' prevent using java/script/INS
Const MAX_PATH = 260
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUserName As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
Private Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias "FtpGetCurrentDirectoryA" (ByVal hFtpSession As Long, ByVal lpszCurrentDirectory As String, lpdwCurrentDirectory As Long) As Long
Private Declare Function FtpCreateDirectory Lib "wininet.dll" Alias "FtpCreateDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
Private Declare Function FtpRemoveDirectory Lib "wininet.dll" Alias "FtpRemoveDirectoryA" (ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
Private Declare Function FtpDeleteFile Lib "wininet.dll" Alias "FtpDeleteFileA" (ByVal hFtpSession As Long, ByVal lpszFileName As String) As Boolean
Private Declare Function FtpRenameFile Lib "wininet.dll" Alias "FtpRenameFileA" (ByVal hFtpSession As Long, ByVal lpszExisting As String, ByVal lpszNew As String) As Boolean
Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hConnect As Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Long, ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByRef dwContext As Long) As Boolean
Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hConnect As Long, ByVal lpszLocalFile As String, ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean
Private Declare Function InternetGetLastResponseInfo Lib "wininet.dll" Alias "InternetGetLastResponseInfoA" (lpdwError As Long, ByVal lpszBuffer As String, lpdwBufferLength As Long) As Boolean
Private Declare Function FtpFindFirstFile Lib "wininet.dll" Alias "FtpFindFirstFileA" (ByVal hFtpSession As Long, ByVal lpszSearchFile As String, lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, ByVal dwContent As Long) As Long
Private Declare Function InternetFindNextFile Lib "wininet.dll" Alias "InternetFindNextFileA" (ByVal hFind As Long, lpvFindData As WIN32_FIND_DATA) As Long
Const PassiveConnection As Boolean = True

Private Sub Form_Load()
'KPD-Team 2000
'url: http://www.allapi.net
'E-Mail: KPDTeam@allapi.net
Dim hConnection As Long, hOpen As Long, sOrgPath  As String
'open an internet connection
hOpen = InternetOpen("API-Guide sample program", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
'connect to the FTP server
hConnection = InternetConnect(hOpen, "your ftp server", INTERNET_DEFAULT_FTP_PORT, "your login", "your password", INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0)
'create a buffer to store the original directory
sOrgPath = String(MAX_PATH, 0)
'get the directory
FtpGetCurrentDirectory hConnection, sOrgPath, Len(sOrgPath)
'create a new directory 'testing'
FtpCreateDirectory hConnection, "testing"
'set the current directory to 'root/testing'
FtpSetCurrentDirectory hConnection, "testing"
'upload the file 'test.htm'
FtpPutFile hConnection, "C:\test.htm", "test.htm", FTP_TRANSFER_TYPE_UNKNOWN, 0
'rename 'test.htm' to 'apiguide.htm'
FtpRenameFile hConnection, "test.htm", "apiguide.htm"
'enumerate the file list from the current directory ('root/testing')
EnumFiles hConnection
'retrieve the file from the FTP server
FtpGetFile hConnection, "apiguide.htm", "c:\apiguide.htm", False, 0, FTP_TRANSFER_TYPE_UNKNOWN, 0
'delete the file from the FTP server
FtpDeleteFile hConnection, "apiguide.htm"
'set the current directory back to the root
FtpSetCurrentDirectory hConnection, sOrgPath
'remove the direcrtory 'testing'
FtpRemoveDirectory hConnection, "testing"
'close the FTP connection
InternetCloseHandle hConnection
'close the internet connection
InternetCloseHandle hOpen
End Sub

Public Sub EnumFiles(hConnection As Long)
Dim pData As WIN32_FIND_DATA, hFind As Long, lRet As Long
'set the graphics mode to persistent
Me.AutoRedraw = True
'create a buffer
pData.cFileName = String(MAX_PATH, 0)
'find the first file
hFind = FtpFindFirstFile(hConnection, "*.*", pData, 0, 0)
'if there's no file, then exit sub
If hFind = 0 Then Exit Sub
'show the filename
Me.Print Left(pData.cFileName, InStr(1, pData.cFileName, String(1, 0), vbBinaryCompare) - 1)
Do
'create a buffer
pData.cFileName = String(MAX_PATH, 0)
'find the next file
lRet = InternetFindNextFile(hFind, pData)
'if there's no next file, exit do
If lRet = 0 Then Exit Do
'show the filename
Me.Print Left(pData.cFileName, InStr(1, pData.cFileName, String(1, 0), vbBinaryCompare) - 1)
Loop
'close the search handle
InternetCloseHandle hFind
End Sub

Sub ShowError()
Dim lErr As Long, sErr As String, lenBuf As Long
'get the required buffer size
InternetGetLastResponseInfo lErr, sErr, lenBuf
'create a buffer
sErr = String(lenBuf, 0)
'retrieve the last respons info
InternetGetLastResponseInfo lErr, sErr, lenBuf
'show the last response info
MsgBox "Error " + CStr(lErr) + ": " + sErr, vbOKOnly + vbCritical
End Sub

Gruß
Micha

Anzeige
AW: FTP-Upload 1&1
23.07.2003 09:26:31
andre
hallo michael,
erst mal danke für die antwort. hab's auch gleich probiert - allerdings scheint es in vba nicht zu laufen. bei Public Sub EnumFiles(hConnection As Long)
meckert es erst mal folgende zeile an:
Me.AutoRedraw = True
-unzulässige verwendung des schlüsselwortes me
--> kommt bei kommentierung auch bei den anderen me's
autoredraw gibts zumindest in der hilfe auch nicht, und wenn ich mir die website anschaue vermute ich erst mal, dass es für vb ist?
gruss andre

AW: FTP-Upload 1&1
23.07.2003 09:48:57
Michael Scheffler
Hi,
ja es ist für VB. Ich dactze, dass Dir das Abändern gelingen sollte? Ansonsten schau mal unter:
http://www.vbarchiv.net/workshop/workshop22.ph
Gruß
Micha

Anzeige
AW: FTP-Upload 1&1
23.07.2003 12:21:24
andre
hallo michael,
danke nochmal, ich hab's geschafft - code der ersten antwort. das vba bekomme ich (meistens) hin, nur tue ich mich mit dem internetkram noch ziemlich schwer.
ausschlaggebend war die zeile:
Const INTERNET_OPEN_TYPE_PROXY = 2 ' 3 = via named proxy
stand erst auf 3, und den named proxy habe ich nicht -
dadurch blieben hOpen und hConnect auf 0 und das zweite makro lief bei den entsprechenden prüfungen nicht durch.
nach glücklicherweise nur zwei versuchen - mit 1 und 2 - hat's dann geklappt.
gruss andre

AW: FTP-Upload 1&1
23.07.2003 06:57:18
Hubert Z.
Hallo andre:
Es gibt keinen STOR Befehl! Hier sind alle zur Verfügung stehenden Befehle für ftp: Woher hast Du das Makro? Schau bzgl. ftp lieber mal hier im Forum.
! delete literal prompt send
? debug ls put status
append dir mdelete pwd trace
ascii disconnect mdir quit type
bell get mget quote user
binary glob mkdir recv verbose
bye hash mls remotehelp
cd help mput rename
close lcd open rmdir
Gruß Hubert

Anzeige
AW: FTP-Upload 1&1 noch offen
23.07.2003 07:30:12
andre
hallo hubert,
- das mit den ---> sind die aktions- bzw. ausführungmeldungen vom server. der ftp-befehl ist z.b. ftp> ascii, vom server kommt dann ---> TYPE A. die siehst du auch, wenn du ins protokoll von ftp-programmen wie wise-ftp schaust.
das makro stammt von hier (Beispielarbeitsmappe). die hat das gleiche ergebnis - eine datei mit 0 byte. dann habe ich noch was in der recherche gefunden und alles zusammengestrickt. ... aber vielleicht war es auch nicht vollständig. warum der ftp-befehl der variable staring übergeben wird und dann nicht weitergenutzt ???
hier mal das protokoll von wise-ftp:
auffällig ist, das häufig beim ersten versuch die verbindung nicht hergestellt werden kann. das ist auch beim übertragen der website mit netobjects fusion so.
! Verbinden mit www.a-schau.de...
! Verbindung kann nicht hergestellt werden: www.a-schau.de! ()
! Verbinden mit www.a-schau.de...
< 220 FTP Server ready.
> USER xxxx-xxx
< 331 Password required for xxxx-xxx.
> PASS (verborgen)
< 230 User xxxx-xxx logged in.
> SYST
< 215 UNIX Type: L8
> CWD /
< 250 CWD command successful.
> PWD
< 257 "/" is current directory.
> PASV
< 227 Entering Passive Mode (212,227,119,83,209,183).
> LIST
< 150 Opening ASCII mode data connection for file list
< 226 Transfer complete.
! 3245 Bytes gesendet/empfangen in 0 Sekunden (3523 Bytes/Sekunden)
> CWD /a-schau
< 250 CWD command successful.
> PWD
< 257 "/a-schau" is current directory.
> PASV
< 227 Entering Passive Mode (212,227,119,83,209,192).
> LIST
< 150 Opening ASCII mode data connection for file list
< 226 Transfer complete.
! 380 Bytes gesendet/empfangen in 0 Sekunden (974 Bytes/Sekunden)
! Verbindungsaufbau für Upload/Download...
< 220 FTP Server ready.
> USER xxxx-xxx
< 331 Password required for xxxx-xxx.
> PASS (verborgen)
< 230 User xxxx-xxx logged in.
> TYPE A
< 200 Type set to A
> CWD /a-schau/
< 250 CWD command successful.
> PASV
< 227 Entering Passive Mode (212,227,119,83,209,197).
> STOR CMB.TXT
< 150 Opening ASCII mode data connection for CMB.TXT
< 226 Transfer complete.
! 5 Bytes gesendet/empfangen in 0 Sekunden (7 Bytes/Sekunden)
> MDTM 20030317211108 CMB.TXT
< 550 20030317211108: No such file or directory
> TYPE A
< 200 Type set to A
> PASV
< 227 Entering Passive Mode (212,227,119,83,209,198).
> NLST -la CMB.TXT
< 150 Opening ASCII mode data connection for file list
< 226 Transfer complete.
! 64 Bytes gesendet/empfangen in 0 Sekunden (159 Bytes/Sekunden)
> QUIT
< 221 Goodbye.

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige