Hi All
I am trying to find the users who are all using emacs editor in my linux server and i wrote the following script.
Quote:
#!/bin/bash
#This script is used to find the usage of emacs
#Whether it is being used or not and
#Who and When using the same.
user=`ps -ef |grep emacs |awk '{print $1}'|grep -v root`
process=`ps -ef |grep emacs |awk '{print $8}'|grep -v gre`
echo $user > one.txt
echo $process >> one.txt
`mail -s "$process invoked by $user" kingston@win.com < one.txt
|
The output is as follows, with the subject "emacs"
Quote:
/bin/bash
/bin/bash
emacs invoked by mursir
kinved
mursir kinved
emacs /bin/bash /bin/bash emacs
|
What i expect is a mail with the subject "emacs invoked by mursir kinved", with the following content
mursir kinved
emacs emacs
When i fired the individual commands, i have got the following outputs.
Quote:
[root@einbalx0014 ~]# user=`ps -ef |grep emacs |awk '{print $1}'|grep -v root`
[root@einbalx0014 ~]# echo $user
mursir kinved
[root@einbalx0014 ~]# process=`ps -ef |grep emacs |awk '{print $8}'|grep -v gre`
[root@einbalx0014 ~]# echo $process
emacs emacs
|
Can someone help me to attain the expected result?