Operating System - HP-UX
1833792 Members
2066 Online
110063 Solutions
New Discussion

script to display the grep command to the screen

 
Mohammed Imran
Advisor

script to display the grep command to the screen

Greetings,

I am new to the script this is the 1st time i just wanted to know the how much user login to the particular server and I issued the following command to know:
#ps -ef | grep DEAL* |wc -l

I want the command execute every after to minute to the current screen and display login user connection.

Gentlemen please help me.
Thanks,
Mohammed
6 REPLIES 6
Slawomir Gora
Honored Contributor

Re: script to display the grep command to the screen

Hi,

below simple script

#!/bin/sh

while true
do
clear
echo "Number of logged users = `who | wc -l`"
sleep 60
done

Mohammed Imran
Advisor

Re: script to display the grep command to the screen

hi,
where shall i execute this script, I mean the #ps -ef |grep DEAL* |wc -l:
whre DEAL is a sever whre users logging in.
how do i automate to display on the screen.
Slawomir Gora
Honored Contributor

Re: script to display the grep command to the screen

Hi,

you can execute such script on terminal you are logged to system and output will be displayed on this terminal window.

while true
do
clear
ps -ef |grep DEAL* |wc -l
sleep 60
done



Mohammed Imran
Advisor

Re: script to display the grep command to the screen

hi,
it is ok i manager to execute with the following way:
#!/bin/sh
while true
do
clear
echo "Number of logged user = `ps -ef |grep DEAL* |wc -l`"
sleep 60
done
But after that cursor only blink doesn't give the out put after 2 minutes.
I also would like to add the current time before "Number of logged user "with the output.
thank you.

Thayanidhi
Honored Contributor

Re: script to display the grep command to the screen

Replace the "clear" with "date".
I have doubt, If you want find out current no of users, displaying `who` is best option.

regds
TT
Attitude (not aptitude) determines altitude.
Mohammed Imran
Advisor

Re: script to display the grep command to the screen

hi Thayanidhi,
Acctully i m trying to locate the application user this user using the application and accessing the componet called DEAL server. now it works fine.
thank you,
imran