mtehonica Posted March 15, 2011 Share Posted March 15, 2011 Hi Guys! First time poster, long time AutoIT user! Just wondering if there is an easy way to open a file from an FTP Server. I have a bunch of log files on an FTP and need to open each and do some parsing. Any help would be appreciated! Thanks! Link to comment Share on other sites More sharing options...
hannes08 Posted March 15, 2011 Share Posted March 15, 2011 Hi mtehonica, take a look at the helpfile: _FTP_FileOpen Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
mtehonica Posted March 15, 2011 Author Share Posted March 15, 2011 Hi mtehonica,take a look at the helpfile: _FTP_FileOpen Will do! Thanks! Link to comment Share on other sites More sharing options...
mtehonica Posted March 15, 2011 Author Share Posted March 15, 2011 Alright, so here is what I've come up with so far... #include <FTPEx.au3> $server = 'ftp.address.com' $username = 'username' $pass = 'pass' $Open = _FTP_Open('MyFTP Control') $Conn = _FTP_Connect($Open, $server, $username, $pass) Local $h_Handle $aFile = _FTP_FindFileFirst($Conn, "/status", $h_Handle) for $i = 1 To $aFile[1]+1 Step 1 ConsoleWrite('$Filename = ' & $aFile[10] & ' -> Error code: ' & @error & @crlf) $aFile = _FTP_FindFileNext($h_Handle) Next $FindClose = _FTP_FindFileClose($h_Handle) $Ftpc = _FTP_Close($Open) This is successfully getting the filenames from the directory. Now I need to open the file and parse it for specific words. Any pointers on where to start? Probably _FTP_FileOpen and _FTP_FileRead? Any examples on how to implement this? Thanks! Link to comment Share on other sites More sharing options...
BiBiBi Posted May 24, 2011 Share Posted May 24, 2011 Here is how to open txt file and read from it. #Include <FTPEx.au3> $s_ServerName ='12.12.12.8' $s_Username = 'user' $s_Password = 'pass' $lpszFileName='something.txt' $s_Remote = '/working dir name /' $Open = _FTP_Open('MyFTP Control') $hConnect = _FTP_Connect($Open, $s_ServerName, $s_Username, $s_Password) _FTP_DirSetCurrent($hConnect, $s_Remote) $dwNumberOfBytesToRead = _FTP_FileGetSize($hConnect, $lpszFileName) $h_File = _FTP_FileOpen($hConnect, $lpszFileName) msgbox(0,"",BinaryToString (_FTP_FileRead($h_File, $dwNumberOfBytesToRead))) $Ftpc = _FTP_Close($Open) 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