Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #RequireAdmin
- #include <ButtonConstants.au3>
- #include <ComboConstants.au3>
- #include <EditConstants.au3>
- #include <GUIConstantsEx.au3>
- #include <StaticConstants.au3>
- #include <WindowsConstants.au3>
- #include <FTPEx.au3>
- #include <SFTPEx.au3>
- #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
- #AutoIt3Wrapper_Compression=4
- #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
- #Region ### START Koda GUI section ###
- $GUI = GUICreate("FTP tool", 308, 242, 643, 265)
- GUICtrlCreateLabel("Host", 16, 16, 26, 17)
- GUICtrlCreateLabel("Port", 192, 16, 23, 17)
- GUICtrlCreateLabel("Username", 16, 56, 52, 17)
- GUICtrlCreateLabel("Password", 16, 88, 50, 17)
- GUICtrlCreateLabel("Status : ", 8, 152, 43, 17)
- $status = GUICtrlCreateLabel("Not connected", 52, 152, 221, 17)
- $host = GUICtrlCreateInput("104.225.219.223", 48, 12, 121, 21)
- $port = GUICtrlCreateCombo("22", 224, 12, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
- GUICtrlSetData(-1, "21|80")
- $username = GUICtrlCreateInput("frenkey", 79, 52, 121, 21)
- $password = GUICtrlCreateInput("frenkey_mmo", 79, 81, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
- $connectBtn = GUICtrlCreateButton("CONNECT", 56, 192, 75, 25)
- $disconnectBtn = GUICtrlCreateButton("DISCONNECT", 143, 192, 107, 25)
- GUISetState(@SW_SHOW)
- #EndRegion ### END Koda GUI section ###
- If GUICtrlRead($status) = 'Not connected' Then GUICtrlSetState($disconnectBtn, $GUI_DISABLE) ; disable disconnect button
- GUICtrlSetData($port, '21') ; default port
- Global $status, $host, $port, $username, $password
- While 1
- $nMsg = GUIGetMsg()
- Switch $nMsg
- Case $GUI_EVENT_CLOSE
- Exit
- Case $connectBtn
- _connectFTP()
- EndSwitch
- WEnd
- ; connection to FTP server
- Func _connectFTP()
- Local $_host = "104.225.219.223";GUICtrlRead($host) ; host name
- Local $_username = "frenkey" ;GUICtrlRead($username) ; username
- Local $_password = "frenkey_mmo";GUICtrlRead($password) ; password
- Local $_port = 22 ;GUICtrlRead($port) ; port
- Local $hdir = "/home/frenkey/webapps/GW2-MODS/GW2Minion64/"
- Local $FTPopen = _FTP_Open('FTP connection test') ; name of connection
- Local $FTPConnect = _FTP_Connect($FTPopen, GUICtrlRead($_host), GUICtrlRead($_username), GUICtrlRead($_password), 1, GUICtrlRead($_port),3) ; connect
- ; try to connect to server
- If Not @error Then ; if not error
- _FTP_DirGetCurrent($FTPConnect)
- If @error Then ConsoleWrite("FTP Current dir set : " & @error & @CRLF)
- _FTP_DirSetCurrent($FTPConnect, $hdir)
- If @error Then ConsoleWrite("FTP set dir : " & @error & @CRLF)
- GUICtrlSetData($status, "Connected") ; set status to connected
- GUICtrlSetState($connectBtn, $GUI_DISABLE) ; disable connect button
- Else
- MsgBox(48, 'FTP connection error', "Can't connect to server, error = " & @error) ; if there is connection error
- MsgBox(48, 'Test variables', 'server name = ' & $_host & ', username = ' & $_username & ', password = ' & $_password & ', port = ' & $_port) ; debugg message
- EndIf
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement