![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| substring | panknil | Shell Programming and Scripting | 4 | 10-01-2007 08:12 AM |
| How do I Substring ?? | Rigger | Shell Programming and Scripting | 6 | 04-26-2007 02:26 AM |
| substring | alla.kishore | UNIX for Dummies Questions & Answers | 8 | 01-09-2007 02:57 AM |
| substring using AWK | mahabunta | UNIX for Dummies Questions & Answers | 3 | 09-19-2006 04:47 PM |
| substring | Anika | UNIX for Dummies Questions & Answers | 4 | 09-19-2001 03:10 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I execute command on this file and it gives o/p like this.
COMMAND $ fuser -f /clocal/sanjay/AccessMonitor /clocal/sanjay/AccessMonitor: 1368322c To truncate 'c', i used tr -dc "[:digit:]\n" but then it does't give 1368322 as O/P. Any help ?? |
|
||||
|
Quote:
fuser -f /clocal/sanjay/AccessMonitor > tempfind.txt pid = cat tempfind.txt | tr -dc "[:digit:]\n" echo "$pid" When prompt I run the above command, it gives.... $ fuser -f /clocal/AccessMonitor /clocal/AccessMonitor: 1368322c Now I want the no. (without ant character) into the variable pid (given above). Any idea ?? |
|
||||
|
Quote:
MYPATH="/clocal/Sanjay/" MAIL_RECIPIENTS="abcx@zzz.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" > tempfind.txt pid = cat tempfind.txt | tr -dc "[:digit:]\n" echo "$pid" ### 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 -w "$pid" | awk '{ print $1 }'` echo " $file_dir access by the $user " >> tempmail.txt done cat tempmail.txt | mailx -s "$Subject" "$MAIL_RECIPIENTS" --------------------------------------------------------------------- Once red faced commands will run successfully, means task is achieved. Now, in variable pid, i am not getting any thing. I want the process no. related to the file accessed, using fuser command. As shown above. Any help will be appreciable. !! |
|
|||||
|
Quote:
Code:
fuser -f "$file_dir" > tempfind.txt pid=$(tr -dc "[:digit:]\n" < tempfind.txt) |
|
||||
|
please check once again !!
Quote:
Don;t you think that to redirect the contents from the tempfind.txt file, unix creates a saperate process with unique Porcess id. And to truncate it creates another process with unique process id. I think above command will club the process ids. (of all the processes used in above command) to one id, hence this clubbed id won;t be able get from ps table. Its not working, means not giving the name of the user from the ps table according to the process id. Please check it !! Thanks in advance !! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|