Howdy,
I am trying to make a script which first greps 'failed' messages and puts them into file.
Then I need to read each line and send them i.e as a separate mailx message.
Here first tested with echo-command to see the output:
So how to read a line as a string so that it would handle each row as a entire line.
/tmp/logfile.log (looks like this)
" Login for user xxxx failed "
" Login for user yyyy was ok "
" Login for user zzzz failed "
============================
#!/bin/sh
grep failed /tmp/logfile.log > /tmp/failed.log
for i in `cat /tmp/failed.log`
do
echo $i
done
Output should look like this
" Login for user xxxx failed "
" Login for user zzzz failed "
but it looks like this
"
Login
for
user
xxxx
failed
"
"
Login
for
user
zzzz
failed
"
------------
So I wonder how to fix this prob,
#Kimmers
I am trying to make a script which first greps 'failed' messages and puts them into file.
Then I need to read each line and send them i.e as a separate mailx message.
Here first tested with echo-command to see the output:
So how to read a line as a string so that it would handle each row as a entire line.
/tmp/logfile.log (looks like this)
" Login for user xxxx failed "
" Login for user yyyy was ok "
" Login for user zzzz failed "
============================
#!/bin/sh
grep failed /tmp/logfile.log > /tmp/failed.log
for i in `cat /tmp/failed.log`
do
echo $i
done
Output should look like this
" Login for user xxxx failed "
" Login for user zzzz failed "
but it looks like this
"
Login
for
user
xxxx
failed
"
"
Login
for
user
zzzz
failed
"
------------
So I wonder how to fix this prob,
#Kimmers