09-29-2007
Quote:
Originally Posted by
varungupta
Hey ,
When I run the script it gives me following error :
AccessLogMonitor_script[11]: 0403-057 Syntax error at line 23 : `
"' is not matched.
And my script is, as per your suggestions :
---------------------------------------------------------------------
#SCRIPT TO CHECK WHO HAS ACCESSED THE LOG/FILE IN PAST 'N' MINUTES, AND MAIL ACCORDINGLY.
MYPATH="/clocal/mqbrkrs/user/mqsiadm/sanjay/"
MAIL_RECIPIENTS="abc@xyz.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
pid = `fuser -f $file_dir`
### Find out the owner/user name for that Process
### Replace the $access_user_filed with the filed no from the ps -ef
### command
user = `ps -ef | grep $pid | awk { print $1 }`
echo " $file_dir access by the $user " >> tempmail.txt "
done
cat tempmail.txt | mailx -s "$Subject" "$MAIL_RECIPIENTS"
---------------------------------------------------------------------
Suggest me !!
Thanks !!
Any help, I would appriciate !!
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I am writing a script that periodically reads in data from a text file. The only issue is that, that text file is periodically updated (appended to) by another script. I am using perl in UNIX environment. How can I check if that text file is being accessed, so I can wait until it is no longer being... (6 Replies)
Discussion started by: rickylui
6 Replies
2. Shell Programming and Scripting
Hi,
I need to count the number of times a script is accessed from within the script. Is it possible ?
Example: I have a script called lo.sh and i execute the script for the first time, then the counter variable declared inside the lo.sh should increment by 1. For every execution the... (1 Reply)
Discussion started by: pathanjalireddy
1 Replies
3. UNIX for Dummies Questions & Answers
how can I use 'ls' to list file which is accessed yesterday? Thx :confused: (2 Replies)
Discussion started by: aaron_fong
2 Replies
4. Shell Programming and Scripting
when unix is logged in it access some login file depending on the shell
like .cshrc , .login , .vimrc , .bashrc
how can we know which is being access in a perticular unix flavor. (1 Reply)
Discussion started by: useless79
1 Replies
5. Shell Programming and Scripting
Hi all,
I will thankful if anybody helps me in finding out the users who accessed any of our files.
Thanks in advance
Chanakya (2 Replies)
Discussion started by: Chanakya.m
2 Replies
6. AIX
Hey,
I want to ask a simple Question....
How would I be able to come to know that files/directoires in a Parent directory has been accessed (means contents of the file has been just viewed) by the user(s) in a group ? and mail the name(s) of those files/directories which has been accessed... (1 Reply)
Discussion started by: varungupta
1 Replies
7. Shell Programming and Scripting
Hello, is there maybe a way to check if a specific file is being accessed at the moment?
Example:
You will start copying a 10 GB file from A to B, how could I code it so my script actually knows when file B is finished copying? (1 Reply)
Discussion started by: TehOne
1 Replies
8. UNIX for Advanced & Expert Users
Hi All,
is there any command or script to find out last five users who have accessed a file
thanks
jcpratap (1 Reply)
Discussion started by: Jcpratap
1 Replies
9. UNIX for Dummies Questions & Answers
I can do an ls -l CD* and see the following CDTEST userA RW RW R and I an logged on as userA. But if I do an ls -l the file does not appear. If I do a vi CDTEST it tries to create a new file named CDTEST. If I do a mv or rm I get the message no file of name CDTEST found. Any idea what is going on.... (3 Replies)
Discussion started by: LeeT
3 Replies
10. UNIX for Beginners Questions & Answers
Hi All,,
I need to find the latest files that are accessed less than 10mins in a particular directory & send those files in an attachment.
I could use the below simple one. But if the directory was not updated any recently i could mail the old file again, i need to eliminate that.. What shld... (8 Replies)
Discussion started by: Jeevitha
8 Replies
LEARN ABOUT SUNOS
pathconv
pathconv(1F) FMLI Commands pathconv(1F)
NAME
pathconv - search FMLI criteria for filename
SYNOPSIS
pathconv [-f] [-v alias]
pathconv [-t] [-l] [-nnum] [-v string]
DESCRIPTION
The pathconv function converts an alias to its pathname. By default, it takes the alias as a string from the standard input.
OPTIONS
-f If -f is specified, the full path will be returned (this is the default).
-t If -t is specified, pathconv will truncate a pathname specified in string in a format suitable for display as a frame title. This
format is a shortened version of the full pathname, created by deleting components of the path from the middle of the string until
it is under DISPLAYW -- 6 characters in length, and then inserting ellipses ( ... ) between the remaining pieces. Ellipses are
also used to show truncation at the ends of the strings if necessary, unless the -l option is given.
-l If -l is specified, < and > will be used instead of ellipses ( ... ) to indicate truncation at the ends of the string generated by
the -t option. Using -l allows display of the longest possible string while still notifying users it has been truncated.
-nnum If -n is specified, num is the maximum length of the string (in characters) generated by the -t option. The argument num can be
any integer from 1 to 255.
-valias |string If the -v option is used, then alias or string can be specified when pathconv is called. The argument alias must be an
alias defined in the alias_file named when fmli was invoked. The argument string can only be used with the -t option and must be a
pathname.
EXAMPLES
Example 1: A sample that uses pathconv to construct the menu title. It searches for MYPATH in the alias_file named when fmli command.
Here is a menu descriptor that uses pathconv to construct the menu title. It searches for MYPATH in the alias_file named when fmli was
invoked:
menu=`pathconv -v MYPATH/ls`
.
.
.
where there is a line in alias_file that defines MYPATH. For example, MYPATH=$HOME/bin:/usr/bin.
Here is a menu descriptor that takes alias from the standard input.
menu=`echo MYPATH/ls | pathconv`
.
.
.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
fmli(1), attributes(5)
SunOS 5.10 5 Jul 1990 pathconv(1F)