Shell Parsing FTP log

Hello again,

I'm trying to write a small shell script which watches the FTP log (/var/log/xferlog) and sends e-mail when a file is uploaded.

The problem I have: How to extract path and file names which contain spaces (or possibly other special characters)?

I know that the field in the log which follows the path/file name always has the string "uploaded". I can determine which field matches the string "uploaded". Since I also know which field contains the beginning of the path (if it contains spaces), I can find the fields which make up the entire path and thus return the correct path/file name.

Is this a reasonable approach?

If yes, how can I assign the returned value to a variable name? For example:

$ echo $field
Code:
8

I'd like to do something like:

Code:
awk '{print $($field)}'

Which of course doesn't work.

Would you please advise?
 
Last edited by a moderator:
Back
Top