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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why am I getting this error? Please Help.

Status
Not open for further replies.

tijerina

Vendor
Mar 4, 2003
132
US
I am trying to audit a file against a static base file that resides on the machine (the static base file resides on the machine). My output should have the NUMBER OF FILES and THE NAME OF THE FILES DO NOT MATCH. This is for multiple directories.

Here is what I have and below that is the error.

HELP????

----------Start of Script--------------------

#!/bin/ksh

FILELIST=/DJ/PUB/testfile

typeset -i MISSING=0
typeset -i FOUND=0
typeset -i TOTAL=0

while read -r FILELIST
do
echo ${FILELIST}
if [ ! -f ${FILELIST} ]
then
((MISSING +=1))
print -u2 "ERROR: File Missing: ${FNAME} Files Missing $MISSING"
else
((${FOUND} +=1))
fi
(( TOTAL += 1 ))
done < ${FILELIST}
then

if [ ${MISSING} ]

if [ ${MISSING} ]
then
print -u2 &quot;Of the ${TOTAL} files expected, ${MISSING} were missing!&quot;
else
print &quot;All ${TOTAL} files were found!&quot;
fi

------End Of Script------------

------Start of Error-------------

/REGO/LIBRARY/CAPCHANG
./christij 20: 0: not found
./christij 20: TOTAL: not found
/sdasdfREGO/LIBRARY/DBCHECK
./christij 20: MISSING: not found
ERROR: File Missing: Files Missing 0
./christij 20: TOTAL: not found
/REGO/LIBRARY/DBHTML
./christij 20: 0: not found
./christij 20: TOTAL: not found
/REGO/PREFS/CAPPRIME
./christij 20: 0: not found
./christij 20: TOTAL: not found
./christij 21: syntax error: got then, expecting Newline

-----------End Of Error--------------------------------

Is there a way for me to output the results to a file.
The end result should be an output file that will give the name of the machine..Example

On Machine Alpha
You have 2 missing files, they are /Dir/Subdir/missingfile, /Dir/Subdir/Missingfile2


Please help..
 
Hi,
it is well that you read from FILELIST into the same FILELIST ? (op read an done)
Regards Boris.
 
There is a &quot;then&quot; after the first &quot;done&quot;. That is causing the error. There is also an &quot;if&quot; just after that which doesn't have a &quot;then&quot;. That will cause an error as well.

The issue that Boria cites will cause problems as well. It looks like you inteded to use FNAME but didn't change it everywhere.

while read -r FNAME
do
echo ${FNAME}
if [ ! -f ${FNAME} ]
then
((MISSING +=1))
print -u2 &quot;ERROR: File Missing: ${FNAME} Files Missing $MISSING&quot;
else
((${FOUND} +=1))
fi
(( TOTAL += 1 ))
done < ${FILELIST}
 
Boria,

I am not sure what you mean with your question. You help will greatly be appreciated. Am I reading the wrong file, I am sure I have a mis match somewhere, but I can't find it.

Can you assist or anybody outhere in script world?

Thanks to all.
 
You've typoed a bunch of errors into the script. See your other thread for corrections...

thread822-496816
Also, to increment a variable, it's...
[tt]
(( FOUND += 1 )) [/tt]not[tt] (( ${FOUND} += ))
[/tt]
From all the threads you've been posting on this, you have been given everything you need.

Hope this helps.

 
SamBones,

I am not a pro at this and deciphering what others have said is kind of difficult for me. I do thank you and all for everything and I am using all that is given. I was sure that some errors were given, but again, it is hard for me to decipher what is wrong or where the error is. Sometimes things have to be gerber fed to me.

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top