dloszewski
asked on
Perl Pattern searching help with ftp flows
I apologize in advance for my ignorance in perl, I'm unfortunately a beginner and am attempting teach myself as I go along with some video tutorials and books and help from you guys.
Ok, so I wrote a script in bash to show the entire flow of a ftp connection by searching username or IP address. I had it read the data into an array, search for criteria, and then match that process id with others so I would get the entire flow.
The performance however was extremely slow and from suggestion of others on the experts exchange community I decided to give it a try in perl. I am attempting to learn as much as I can but still have a long way to go. I'm attempting to search for criteria, take the process id of that line, and then read all the lines into an array that matches that process id so I'm basically getting the entire flow of the ftp connection.
I'm assuming I would read each line in from the file, do a pattern match on it and if it matches to the IP address that I'm searching for I would then copy that line to an array. I'm then thinking that after I read those lines into the array I'll go back and grab the process id from each of those lines, do another search on the file and put all the lines matching the process id into a new array, and then print the array out.
Does this sound about right? Any suggestions would help. Thanks.
examples of data in log file:
Ok, so I wrote a script in bash to show the entire flow of a ftp connection by searching username or IP address. I had it read the data into an array, search for criteria, and then match that process id with others so I would get the entire flow.
The performance however was extremely slow and from suggestion of others on the experts exchange community I decided to give it a try in perl. I am attempting to learn as much as I can but still have a long way to go. I'm attempting to search for criteria, take the process id of that line, and then read all the lines into an array that matches that process id so I'm basically getting the entire flow of the ftp connection.
I'm assuming I would read each line in from the file, do a pattern match on it and if it matches to the IP address that I'm searching for I would then copy that line to an array. I'm then thinking that after I read those lines into the array I'll go back and grab the process id from each of those lines, do another search on the file and put all the lines matching the process id into a new array, and then print the array out.
Does this sound about right? Any suggestions would help. Thanks.
examples of data in log file:
Dec 1 23:59:03 sslmftp1 ftpd[4152]: USER xxxxxx
Dec 1 23:59:03 sslmftp1 ftpd[4152]: PASS password
Dec 1 23:59:03 sslmftp1 ftpd[4152]: FTP LOGIN FROM 172.19.x.xx [172.19.x.xx], xxxxxx
Dec 1 23:59:03 sslmftp1 ftpd[4152]: PWD
Dec 1 23:59:03 sslmftp1 ftpd[4152]: CWD /test/data/872507/
Dec 1 23:59:03 sslmftp1 ftpd[4152]: TYPE Image
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Awesome, thanks!
Can you give an example of what the result of processing that data should look like?