Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am trying to go into a file that

Status
Not open for further replies.

ryanildo

Programmer
Jun 26, 2002
5
US
I am trying to go into a file that has already been set up as a variable, $FTPDB_FILE. Once in the file, I need to grep for the 8th field of each of the files listed. Once I grep that 8th field, the results can be three different things: ndm, ssl, or a no/yes which means the file was sent via ftp. I need to then say that if the result of the grep is not ndm or ssl, that the result means the file was ftp'd. Then I need to say otherwise the file was either ndm or ssl(depending on what the file specifically listed.) At that point I need to send the results of the grep to the subject line of an e-mail. so far this is what I have:

determine_connection_type()
{
grep $FTPDB_FILE | cut -d ";" -f1,8| uniq -c

if [ $RESULT -ne `NDM` or `SSL` ]
then
$RESULT = `FTP`

else ???????

Another part of my script lists the e-mail function:

send_email()
{
echo "`date` \nCannot send files via $RESULT to ABC from `hostname`.

One other dilemma. The file represented by the variable $FTPDB_FILE, has about 9 of the first lines commented out so I would need to ignore any of the lines beginning with a ###.

Thank you in advance to anyone who is willing to help me out with this problem.

Thanks,
ryanildo
 
something to start with:

nawk -f starter.awk $FTPDB_FILE

#------------ starter.awk----------------------
BEGIN {
FIELD=8;
patNDM="ndm"
patSSL="ssl"
}

/^[^#]/ {
method=$FIELD;
if ( $FIELD !~ patNDM && $FIELD !~ patSSL )
method="ftp";

printf("Cannot send file via %s\n", method);
}

#------------ starter.awk---------------------- vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top