nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

same C shell question

This is a discussion on same C shell question within the Shell scripting forums, part of the Development/Scripting category; Use man ps to take a look at how to use ps in some advanced way. You are required to ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 02-06-2006, 01:23 AM
TOPHUMAN
Guest
 
Posts: n/a
Default same C shell question

Use man ps to take a look at how to use ps in some advanced way. You are
required to create a shell script called advcps.
advcps will display a menu (using select command), letting a user choose the criteria
he/she prefers to display the information about all the processes running in the system.
advcps should provide the options to: (1) display all the processes based on the
alphabetical order of their creators; (2) display all the processes based on the size of
memory they are using (from high to low); (3) display all the processes based on the CPU
time they have consumed (from high to low); (4) display all the process based on their
priorities (from high to low).
advcps should also provide an option to let the user exit itself.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-06-2006, 04:10 AM
TOPHUMAN1
Guest
 
Posts: n/a
Default my code

Code:
#!/bin/bash

       $VAR=VAR
       echo "Please enter the user's name"
       read VAR
      if  [ $VAR = 1 ] ; then

             top | grep $VAR
      else
            echo "Not have this user"
      fi
I make this code but they can't store the read varable to my top | grep $VAR,why
Reply With Quote
  #3 (permalink)  
Old 02-06-2006, 02:23 PM
sweta's Avatar
Contributors
User
 
Join Date: Feb 2005
Location: New Delhi
My distro: Suse, RHEL, Vista
Posts: 154
Rep Power: 4
sweta will become famous soon enough
Default

Okai, here is corrected script , try out
Code:
#!/bin/bash
VAR=""
echo "Please enter the user's name"
read VAR
if  [ $VAR != "" ] ; then
       top | grep $VAR
else
     echo "Not have this user"
fi
Lemme know...
__________________
Friends - v-nessa - missyAdmin - LinuxChix
Reply With Quote
  #4 (permalink)  
Old 02-09-2006, 04:24 AM
TOP TOP is offline
Junior Member
 
Join Date: Feb 2006
Posts: 4
Rep Power: 0
TOP
Default here it is

No,they are not working ,and only get the input message :

please inter thr user's name

myuser name

Don't have this user!


looks this code cannot store the user name varable to seach at server!

and my first code is working if i type the user name is : "1".i don't know

why, ^^
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
phpmyadmin question paul555 Databases servers 2 07-13-2007 09:27 AM
Squid Question asterisk Linux software 2 05-17-2007 05:52 PM
C question TOP Coding in General 1 07-08-2006 01:14 AM
C question TOP Coding in General 3 03-11-2006 12:08 AM
question TOPHUMAN Shell scripting 1 02-06-2006 02:25 PM


All times are GMT +5.5. The time now is 07:40 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36