Click to See Complete Forum and Search --> : shellscript needed


strong
06-03-2002, 02:01 PM
:) Hi, friends of Linux! :)

I need the following shell script but unfortunately I have no idea how to code it.
Your help is really appreciated.

You should call the script in the following way.

user [200][user.txt]

What shall the script do?

It shall show you the user who are logged on (I think the commands who or w are necessary.)

It shall also show you the number of processes each user has started at this moment.

Smith /6
Washington /2
Torvald /3
Gates /4

It would also be nice if the users are shown in a line.

Smith: 6, Washington: 2, Torvald: 3, Gates: 4

The script should run in the background.

Optional you can give a time in seconds when the data should be refreshed. The default should be 120 seconds. The data should be written in a text file like user.txt but the default file name is logon.txt

Every idea is welcome. If you have better ideas you can also modify my suggestions.

Please answer in this forum or send me a message.

:D :D S T R O N G :D :D
strong@cheerful.com

strong
06-03-2002, 02:13 PM
It would be really great if you could send me a shellscript for my problem.

I would prefer bash as shell, but if you prefer other types of shell like ksh you are also welcome.

:cool: :cool: S T R O N G :cool: :cool:
strong@cheerful.com

undef
06-03-2002, 02:19 PM
it helps if you can tell us what you've done so we don't repeat what you already know.

based on what i've gathered so far, you need the who command to get the names of logged on users.
for each user, use grep with ps au to display the processes the user is currently running.

the script should run at the background. simple append & when you execute the script like this myscript &

you want to refresh so put the entire code in an infinite while loop, use sleep to nap for X seconds and repeat.

[ 03 June 2002: Message edited by: undef ]

strong
06-03-2002, 02:54 PM
Thank you for your great help.

I am a bloody new script kiddy, so you cannot give me too much advice.

I have not much experience in coding shell scripts. But I would understand each script.

;) ;) S T R O N G ;) ;)
strong@cheerful.com