offle Posted October 31, 2014 Share Posted October 31, 2014 Hi all, I have a problem with the _FTP_Command (FTPEx.au3). I want to send a command to my server, but this funtion doesn't work and I cannot find my problem/error in the code. All other functions (e.g. _FTP_ListToArray,...) are working fine. I searched the web for this funktion but none of the results from goolge worked for me. Thanks for your help. Func start() reset() Local $sServer = GUICtrlRead($gui_ip) Local $sUsername = GUICtrlRead($gui_user) Local $sPass = GUICtrlRead($gui_pw) Local $cmd = GUICtrlRead($gui_cmd) GUICtrlSetData($Log,'Server: '&$sServer) GUICtrlSetData($Log,'User: '&$sUsername) GUICtrlSetData($Log,'PW: '&$sPass) GUICtrlSetData($Log,'Command: '&$cmd) GUICtrlSetData($Log,'--------------------------------------------------------------------------------') Local $hOpen = _FTP_Open('MyFTP Control') GUICtrlSetData($Log,'Open: '&$hOpen) Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass) GUICtrlSetData($Log,'Connect : '&$hConn) Local $hcmd = _FTP_Command($hConn, $cmd) If @error Then GUICtrlSetData($Log,'CommandError: '&@error) Else GUICtrlSetData($Log,'Command: '&$hcmd) EndIf Local $iFtpc = _FTP_Close($hConn) GUICtrlSetData($Log,'Close1: '&$iFtpc) Local $iFtpo = _FTP_Close($hOpen) GUICtrlSetData($Log,'Close2: '&$iFtpo) GUICtrlSetData($Log,' --->End') EndFunc Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 31, 2014 Moderators Share Posted October 31, 2014 You have error checking at the point of your _FTP_Command, but not before. How are you sure that _FTP_Open and _FTP_Connect are not failing if you're not checking for errors? Beyond that, without seeing the full code with the command you're trying to send, it is a little difficult to troubleshoot for you. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
offle Posted October 31, 2014 Author Share Posted October 31, 2014 Hi, thanks for the quick response. Now I check the errors at open and connect. Additional i added a _FTP_FileGet to check, if the connection is ok and the access to the host works. The command is a "quote rcmd crtlib ascowx" which means to create a Library at an IBM power with IBM i V7R1M0 (better known as OS/400) running on it. the command works without any problem if i try it woth the Windows FTP Client: C:\>ftp 192.168.100.193 Verbindung mit 192.168.100.193 wurde hergestellt. 220-QTCP at DESUP01. 220 Connection will close if idle more than 5 minutes. Benutzer (192.168.100.193:(none)): careman 331 Enter password. Kennwort: 230 CAREMAN logged on. ftp> quote rcmd crtlib ascowx 250 Command crtlib ascowx successful. ftp> Here's my script expandcollapse popup#include <FTPEx.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\oleprivat\Googledrive\DEV\Autoit\Projekte\FTP Test\Form1.kxf $Form1_1 = GUICreate("savftool beta3", 1128, 430, 303, 166) $MenuItem1 = GUICtrlCreateMenu("Datei") $MenuItem3 = GUICtrlCreateMenuItem("Beenden", $MenuItem1) $MenuItem2 = GUICtrlCreateMenu("?") $MenuItem4 = GUICtrlCreateMenuItem("Über", $MenuItem2) $gui_go = GUICtrlCreateButton("Ausführen", 24, 232, 75, 25) $gui_ip = GUICtrlCreateInput("192.168.100.193", 24, 72, 121, 21) $gui_user = GUICtrlCreateInput("careman", 24, 104, 121, 21) $gui_pw = GUICtrlCreateInput("xxxxxx", 24, 136, 121, 21) $Log = GUICtrlCreateList("", 256, 16, 833, 310, BitOR($LBS_NOTIFY,$WS_VSCROLL,$WS_BORDER)) GUICtrlSetData(-1, "") GUICtrlSetFont(-1, 10, 400, 0, "Courier New") $gui_cmd = GUICtrlCreateInput("quote rcmd crtlib ascowx", 24, 176, 185, 21) $gui_end = GUICtrlCreateButton("Beenden", 120, 232, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Func reset() GUICtrlSetData($Log,"") EndFunc Func start() reset() ;Verbindungskram Local $sServer = GUICtrlRead($gui_ip) Local $sUsername = GUICtrlRead($gui_user) Local $sPass = GUICtrlRead($gui_pw) Local $cmd = GUICtrlRead($gui_cmd) GUICtrlSetData($Log,'Server: '&$sServer) GUICtrlSetData($Log,'User: '&$sUsername) GUICtrlSetData($Log,'PW: '&$sPass) GUICtrlSetData($Log,'Befehl: '&$cmd) GUICtrlSetData($Log,'------------------------------------------------------------------------------------------') ;Verbindung zum Server Local $hOpen = _FTP_Open('MyFTP Control') If @error Then GUICtrlSetData($Log,'OpenError: '&@error) Else GUICtrlSetData($Log,'Open: '&$hOpen) EndIf Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass) If @error Then GUICtrlSetData($Log,'Connecterror: '&@error) Else GUICtrlSetData($Log,'Connect: '&$hConn) EndIf ;Befehle Local $hcmd = _FTP_Command($hConn, $cmd) If @error Then GUICtrlSetData($Log,'CommandError: '&@error) Else GUICtrlSetData($Log,'Command: '&$hcmd) EndIf ;Test Local $hList = _FTP_FileGet($hConn, "/home/man/sco.txt", "C:\temp\test.txt") If @error Then GUICtrlSetData($Log,'FileError: '&@error) Else GUICtrlSetData($Log,'File: '&$hcmd) EndIf ;Verbindung dichtmachen Local $iFtpc = _FTP_Close($hConn) GUICtrlSetData($Log,'Close1: '&$iFtpc) Local $iFtpo = _FTP_Close($hOpen) GUICtrlSetData($Log,'Close2: '&$iFtpo) GUICtrlSetData($Log,' --->Ende') EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MenuItem3 Exit Case $MenuItem4 MsgBox(0,"Hup Hup", "Möööp") Case $gui_go start() Case $gui_end Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
offle Posted November 25, 2014 Author Share Posted November 25, 2014 bump?!? Link to comment Share on other sites More sharing options...
Michiel Posted December 2, 2014 Share Posted December 2, 2014 (edited) I'm having problems with the FTPex UDF myself (Hanging after getting a certain amount of files, varies slightly). If you're saying it works fine in the commandline Windows FTP-client, then I think you've narrowed down the problem to inside the UDF, rather than somewhere in Wininet.dll. Perhaps you should load the dll and do it yourself: http://msdn.microsoft.com/en-us/library/windows/desktop/aa384133%28v=vs.85%29.aspx Edited December 2, 2014 by Michiel Link to comment Share on other sites More sharing options...
Michiel Posted December 2, 2014 Share Posted December 2, 2014 So, just for reference, this is the code inside FTPEx.au3 you are trying to use. Note the use of DllCall, if you want to DIY, this is your example. ; #FUNCTION# ==================================================================================================================== ; Author ........: Bill Mezian ; Modified.......: ; =============================================================================================================================== Func _FTP_Command($l_FTPSession, $s_FTPCommand, $l_Flags = $FTP_TRANSFER_TYPE_ASCII, $l_ExpectResponse = 0, $iContext = 0) If $__g_hWinInet_FTP = -1 Then Return SetError(-2, 0, 0) Local $ai_FTPCommand = DllCall($__g_hWinInet_FTP, 'bool', 'FtpCommandW', 'handle', $l_FTPSession, 'bool', $l_ExpectResponse, 'dword', $l_Flags, 'wstr', $s_FTPCommand, 'dword_ptr', $iContext, 'ptr*', 0) If @error Or $ai_FTPCommand[0] = 0 Then Return SetError(-1, _WinAPI_GetLastError(), 0) Return SetError(0, $ai_FTPCommand[6], $ai_FTPCommand[0]) EndFunc ;==>_FTP_Command Link to comment Share on other sites More sharing options...
offle Posted December 4, 2014 Author Share Posted December 4, 2014 Thanks for your response. I don't understand the 'FtpCommandW'. In the dll-help I can only find the 'FtpCommand'. Do you know, why? Link to comment Share on other sites More sharing options...
Michiel Posted December 6, 2014 Share Posted December 6, 2014 That's just the Unicode version of http://msdn.microsoft.com/en-us/library/windows/desktop/aa384133%28v=vs.85%29.aspx Unicode and ANSI names FtpCommandW (Unicode) and FtpCommandA (ANSI) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now