Hi all,
I have the following script:
-------------------------------------------------
#SCRIPT TO CHECK WHO HAS ACCESSED THE LOG/FILE IN PAST 'N' MINUTES, AND MAIL ACCORDINGLY.
MYPATH="/clocal/mqbrkrs/user/mqsiadm/sanjay/"
MAIL_RECIPIENTS="vg517@dcx.com"
Subject="File accessed in last few minutes are ::"
>tempmail.txt
>tempfind.txt
## List all the files which one accessed since last 1 min #####
for file_dir in `find $MYPATH -amin -1`
do
### Find out the PID for that files which one been accessed
echo `fuser -uf "$file_dir" | tr -dc "[:digit:]" ` 1>> tempmail.txt
echo " $file_dir is being accessed" >> tempmail.txt
done
cat tempmail.txt | mailx -s "$Subject" "$MAIL_RECIPIENTS"
-------------------------------------------------
fuser command returns process id, to the file "tempmail.txt" and also prints the output to the STDOUT., both the outputs are different.
output to the file tempmail.txt :
-----------------------------------------------
335936
/clocal/mqbrkrs/user/mqsiadm/sanjay/ is being accessed
594010880672541182872816
/clocal/mqbrkrs/user/mqsiadm/sanjay/AccessMonitor is being accessed
541182
/clocal/mqbrkrs/user/mqsiadm/sanjay/AccessMonitor/AccessLogMonitor_script is being accessed
----------------------------------------------
output to the STDOUT :----------------------------------------------
/clocal/mqbrkrs/user/mqsiadm/sanjay/: c(mqsiadm)
/clocal/mqbrkrs/user/mqsiadm/sanjay/AccessMonitor: c(mqsiadm)c(mqsiadm)c(mqsiadm)c(mqsiadm)
/clocal/mqbrkrs/user/mqsiadm/sanjay/AccessMonitor/AccessLogMonitor_script: (mqsiadm)
-----------------------------------------------
I WANT the output of STDOUT should be present in file tempmail.txt.
In the script i have done `command 1>> filename` but its not working. Please give me the solution to this.
Thanks a lot.
Varun