The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Regarding Shell Scripting anilkarikkandar UNIX for Dummies Questions & Answers 3 11-19-2006 09:26 PM
HELP PLS!! Shell Scripting!! Mary_xxx Shell Programming and Scripting 9 09-16-2006 03:52 AM
difference between AIX shell scripting and Unix shell scripting. haroonec Shell Programming and Scripting 2 04-12-2006 05:12 AM
something else on shell scripting master_6ez Shell Programming and Scripting 1 11-21-2004 08:42 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-02-2008
Registered User
 

Join Date: Feb 2008
Posts: 4
Red face need some help on shell scripting..

hi everyone.. i'm a noob on shell programming and am doing some scripting.. but i really have a lot of trouble getting started.. i need to write a simple shell scripting.. it goes something like this..

for eg if i press '1', it'll show processes for the current user namely
- process id
- parent process id
- user name
- command
- CPU utilization (in desc)
- process start time
- process status

and output it to a file named whatever.txt..

if i press '2' it reports those processes selected in (1) with CPU utilization not equal to 0

if i press '3' it displays all the child processes (with process id, command) of the user specified process

if i press '4' it kills all the process with specified program(command) name on behalf of the user

can all these be done..? argh.. really need a headstart on how to do these.. any help/advice would be appreciated.. thanks..
Reply With Quote
Forum Sponsor
  #2  
Old 02-02-2008
asarch's Avatar
Registered User
 

Join Date: Sep 2006
Posts: 1
It looks like if it were a homework!
Reply With Quote
  #3  
Old 02-02-2008
Registered User
 

Join Date: Feb 2008
Posts: 4
it's considered more as a 'challenge'.. =D my friend showed me what he could do with bash and it seems fun so i'd like to see if i can do it myself.. but it's my first time hands on at bash.. so i need a like you know 'headstart'..?
Reply With Quote
  #4  
Old 02-02-2008
DukeNuke2's Avatar
Soulman
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 1,487
yes, everything you want, can be done! it's a lot of work but you will learn a lot of usefull things...
good luck...

p.s. have a look at the output of "ps -ef" for a nice processlist and if you pipe it and "grep" for a username... should be a good start
Reply With Quote
  #5  
Old 02-02-2008
Registered User
 

Join Date: Jan 2008
Posts: 328
Why not ask your "friend" how he did it? The first thing to do is break open the manual for the operating system you are using and read the system commands it has available. Like the one DukeNuke2 mentions above. What you need do from there is write some shell code to run the commands, grab the output and parse it for the specific data you are interested in and display it however you want. If you are a good learner you will have something written by the end of the day.
Reply With Quote
  #6  
Old 02-03-2008
Registered User
 

Join Date: Jan 2008
Posts: 5
#!/bin/bash

here u go.. headstart..
Reply With Quote
  #7  
Old 02-03-2008
Registered User
 

Join Date: Feb 2008
Posts: 1
the "friend" that gave you this challenge = your teacher ?

you might want to play around with pipe, redirection, sed, grep, awk, those should be able to help you, read up especially on their manuals.

Last edited by faifai; 02-03-2008 at 09:29 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0