Help me with daily monitoring script

Can we see output from ls -l too. That's a lower case L flag.

Regards,
Robin

find /usr/IBM/FileNet/BulkUploaderScript/$i/Log/SuccessLog \
   \( -newer range_start -a \! -newer range_end \) \
   | while read file
do
    lines=`wc -l "$file"`---->i need number of lines in the file  but i am getting filename also  as shown below in the output
   ls -l "$file" | read w x y z d1 d2 d3 rest--> it is not intializing variables but how to  do that , i need basically lastmodification time rather than all infromation 
echo "File $file has $lines lines and a date of $d1 $d2 $d3" 
  done

OUPUT:

File /usr/IBM/FileNet/BulkUploaderScript/LogsFolder/Log/SuccessLog/CSVSuccessLogHIPAACERTS7-6-2013 15-32-18.csv has 4
/usr/IBM/FileNet/BulkUploaderScript/LogsFolder/Log/SuccessLog/CSVSuccessLogHIPAACERTS7-6-2013 15-32-18.csv lines and a date of

Please give a sloution .

I am not able to see any output for that paticular ls-l

ls-l is not working , i mean it is not showing any output . please go through the above code in previous posts , if we do a minor change code will work . Please look into it and help

Do you have a space between ls & -l ?

When you say no output, do you mean absolutely nothing at all except that the prompt returns? You should get something, a total line, an error message, something surely.

Robin

find /usr/IBM/FileNet/BulkUploaderScript/$i/Log/SuccessLog \
   \( -newer range_start -a \! -newer range_end \) \
   | while read file
do
  
  lines=`wc -l "$file"`-----
---->i need number of lines in the file  but i am getting filename also  as shown below in the output     
`ls -l "$file" | read w x y z d1 d2 d3 rest`-----
it is not intializing variables but how to  do that , i need basically lastmodification time ratherecho "File $file has $lines lines and a date of $d1 $d2 $d3" 
    echo $file>>$LOGFILE
done

OUPUT:
for all the lines above written

File /usr/IBM/FileNet/BulkUploaderScript/LogsFolder/Log/SuccessLog/CSVSuccessLogHIPAACERTS7-6-2013 15-32-18.csv has 4
/usr/IBM/FileNet/BulkUploaderScript/LogsFolder/Log/SuccessLog/CSVSuccessLogHIPAACERTS7-6-2013 15-32-18.csv lines and a date of

please suggest any alternative or proper solution

So, can we see the output of just ls -l on it's own in the correct directory. No further scripting, just the plain ls -l thanks.

Thanks,
Robin

find /usr/IBM/FileNet/BulkUploaderScript/$i/Log/SuccessLog \
   \( -newer range_start -a \! -newer range_end \) \
   | while read file
do
  
 lines=`wc -l "$file"`
# details=`ls -l "$file" | read w x y z d1 d2 d3 rest`--->commented ,in this intailzing is problem 
 details=`ls -l "$file"`
 echo $details
 echo "File $file has $lines lines and a date of $d1 $d2 $d3" 
 echo $file>>$LOGFILE
done

OUTPUT:
-rwxrwxrwx 1 ce_admin ce_admin 718 Jun 7 15:32 /usr/IBM/FileNet/BulkUploaderScript/LogsFolder/Log/SuccessLog/CSVSuccessLogHIPAACERTS7-6-2013 15-32-18.csv

File /usr/IBM/FileNet/BulkUploaderScript/LogsFolder/Log/SuccessLog/CSVSuccessLogHIPAACERTS7-6-2013 15-32-18.csv has 4 /usr/IBM/FileNet/BulkUploaderScript/LogsFolder/Log/SuccessLog/CSVSuccessLogHIPAACERTS7-6-2013 15-32-18.csv lines and a date of

I need only last modified date of the file not access time .
And i am getting number of lines with filename but i need only number.
Any alternative or any modifications

:o Okay, I've spotted my first mistake. The output from ls -l "$file" has, of course, five colums to skip (permissions, links, owner, group & bytes) and what I suggested only has four dummy placeholders (w, x, y & z) :rolleyes:

Lets try adding dummy placeholder v to that:-

find /usr/IBM/FileNet/BulkUploaderScript/$i/Log/SuccessLog \
   \( -newer range_start -a \! -newer range_end \) \
   | while read file
do
   lines=`wc -l "$file"`
   details=`ls -l "$file" | read v w x y z d1 d2 d3 rest`
   echo "File \"$file\" has \"$lines\" lines and a date of \"$d1\" \"$d2\" \"$d3\""
   echo $file>>$LOGFILE
done

I've added in a lot of escaped quotes \" so that the output clearly defines each variable to see if I've missed something else.

Can you have a go and post the output in code tags - it makes it easier to read.

Thanks :b:, and apologies :o
Robin

Still facing Issue that d1 ,d2,d3 not printing
Output::

Maybe we shoudl drop the details= bit:-

find /usr/IBM/FileNet/BulkUploaderScript/$i/Log/SuccessLog \
   \( -newer range_start -a \! -newer range_end \) \
   | while read file
do
   lines=`wc -l "$file"`
   ls -l "$file" | read v w x y z d1 d2 d3 rest
   echo "File \"$file\" has \"$lines\" lines and a date of \"$d1\" \"$d2\" \"$d3\""
   echo $file>>$LOGFILE
done

A schoolboy error of mine :o that makes these values would only be set within the sub-shell running the ls -l | read......

Can you actually copy & paste all the code block in, as you output didn't quite tally.

Does that help?

Robin

find /usr/IBM/FileNet/BulkUploaderScript/$i/Log/SuccessLog \
   \( -newer range_start -a \! -newer range_end \) \
   | while read file
do
  
  lines=`wc -l "$file"`
   ls -l "$file" | read v w x y z d1 d2 d3 rest
   echo "File \"$file\" has \"$lines\" lines and a date of \"$d1\" \"$d2\" \"$d3\""
   echo $file>>$LOGFILE
done

Variable "lines" reading filename also with the number of lines in the file .Majorly problem is d1,d2,d3 is not showing any output .What is the solution we have now .

Thanks
Raghavendra

Another variation to see where we're going:-

find /usr/IBM/FileNet/BulkUploaderScript/$i/Log/SuccessLog \
   \( -newer range_start -a \! -newer range_end \) \
   | while read file
do
  lines=`grep -c "" "$file"`
   ls -l "$file" | read v w x y z d1 d2 d3 rest
   echo "File \"$file\" has \"$lines\" lines and a date of \"$d1\" \"$d2\" \"$d3\""
   echo $file>>$LOGFILE
done

That should sort the counting. Testing here, the d1, d2 & d3 works fine for me:-

$ file=.profile
$ lines=`grep -c "" "$file"`
$ ls -l "$file" | read v w x y z d1 d2 d3 rest
$ echo "File \"$file\" has \"$lines\" lines and a date of \"$d1\" \"$d2\" \"$d3\""
File ".profile" has "12" lines and a date of "02" "May" "2012"
$

It would suggest that your code might have ls -1 | read .... instead of ls -l | read .... To clarify, you may have a number one where it needs a lower case L.

Can you have another go?

Robin

ksh reads the last part of the pipe in the current shell:

ls -l "$file" | read v w x y z d1 d2 d3 rest

sh,bash need a work-around:

read v w x y z d1 d2 d3 rest << _EOT
`ls -l "$file"`
_EOT

Or

set -- `ls -l "$file"`
d1=$6; d2=$7; d3=$8