![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| fuction return in perl | jisha | Shell Programming and Scripting | 4 | 05-15-2008 01:51 AM |
| Help Help Help in recursion | murtaza | Shell Programming and Scripting | 6 | 03-29-2007 07:26 AM |
| about memset fuction | ranj@chn | High Level Programming | 3 | 01-31-2006 05:59 AM |
| Get Oracle fuction return value in a variable | rahulrathod | UNIX for Dummies Questions & Answers | 3 | 04-14-2005 09:50 AM |
| recursion | gsjf | Shell Programming and Scripting | 1 | 08-25-2002 09:22 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
|||
|
|||
|
Quote:
Have a look to the Syntax of the script and its giving error inside the function "fun" while redirecting the output to the file. ">>" PLEASE FIND THE CODE .. Code:
SCRIPT TO CHECK WHO HAS ACCESSED THE LOG/FILE IN PAST 'N' MINUTES, AND MAIL ACCORDINGLY.
MYPATH="/clocal/mqbrkrs/user/mqsiadm/varun/"
MAIL_RECIPIENTS="vg@dc.com"
#
Subject=":: LOGS BEING TOUCHED IN THE LAST FEW MINUTES ::"
>tempmail.txt
>tempfind.txt
>filterfile.txt
>tempgrep.txt
#*******************************************************************
## List all the files which one accessed since last 1 min #####
#*******************************************************************
index=1
pidprev=0
ps -ef | grep "\-ksh" | awk '$8 !~ /grep/ { printf "%s %s %s %s %s\n", $1, $2, $3, $5, $8 ; }' >> ./tempfind.txt
for file_dir in `find $MYPATH -amin -1`
do
echo `fuser -uf "$file_dir" ` >> temp.txt.$$
echo " $file_dir is being accessed" >> temp.txt.$$
done
sed -n '/^[ ][a-z]*/p' temp.txt.$$ >> tempmail.txt
echo "Accessed By: " >>tempmail.txt
sed -n '/^[0-9]/p' temp.txt.$$ > filterfile.txt
echo "BEFORE FOR LOOP"
for pid_var in `awk '{ print $1 }' filterfile.txt`
do
echo "**here i am inside the for loop** ";
if [ "$index" -eq 1 ] ; then
echo "**inside if 1. ** " ;
pidprev="$pid_var" ;
echo "pid_var: $pid_var" ;
echo "pidprav: $pidprev" ;
`awk '$2 ~ pid_var {print $3 > "tempgrep.txt" }' tempfind.txt` ;
echo "1. " ;
cat tempgrep.txt ;
echo "----" ;
cat tempgrep.txt | \
while read ppid
do
echo "**inside while loop 1.**"
`awk 'function fun( n, pattern )
{
`awk '{ if($2~n && $1~pattern){
n=$3;
fun( n, pattern ); }
else{
if($2~n && $1!~pattern){
print $1 >> "tempmail.txt" ;
break ;
}
else {next ;}
}
}' tempfind.txt`
}
BEGIN{ pattern = "mqsi[admtsprd]" }
{if ( ppid !~ "" ) { fun( ppid, pattern ); }}
'`
done
let "index+=1" ;
fi
if [ "$pid_var" -ne "$pidprev" ] ; then
echo "**inside if 2. ** " ;
pidprev="$pid_var" ;
echo "pid_var: $pid_var" ;
echo "pidprav: $pidprev" ;
`awk '$2 ~ pid_var {print $3 > "tempgrep.txt" }' tempfind.txt` ;
echo "2. ";
cat tempgrep.txt ;
echo "----" ;
cat tempgrep.txt | \
while read ppid
do
echo "***inside while loop 2. ***"
`awk 'function fun( n, pattern )
{
`awk '{ if($2~n && $1~pattern){
n=$3;
fun( n, pattern ); }
else{
if($2~n && $1!~pattern){
print $1 >> "tempmail.txt" ;
break ;
}
else {next ;}
}
}' tempfind.txt`
}
BEGIN{ pattern = "mqsi[admtsprd]" }
{if ( ppid !~ "" ) { fun( ppid, pattern ); }}
'`
done
fi
done
cat tempmail.txt | mailx -s "$Subject" "$MAIL_RECIPIENTS"
rm -f "temp.txt.*" 2> /dev/null
# >tempmail.txt
# >tempfind.txt
# >filterfile.txt
# >tempgrep.txt
Do let me know the suggestions !! Thanks Varun. |
| Forum Sponsor | ||
|
|
|
#9
|
|||
|
|||
|
Quote:
Code:
var=$(echo outer and $(echo inner) backticks, oh my) |
|
#10
|
|||
|
|||
|
Quote:
Thanks for suggestions. Can you tell me how to resolve that backticks in my code ? As per my code, i am using awk, and how to resolve that nested feature ? Please let me know, appreciate all your help. Varun. |
|
#11
|
|||
|
|||
|
Hint: I wrote "there is an alternative syntax which works". Try it.
|
|
#12
|
||||
|
||||
|
Hey Varun,
Did you got what you wanted or still looking for the solution.. |
|
#13
|
|||
|
|||
|
Quote:
Hope i'll give you good news soon, as far as this script is concerned !! Thanks for being active and joining the forum for this issue. |
|||
| Google The UNIX and Linux Forums |