Sponsored Content
Full Discussion: O/P same as on screen
Top Forums Shell Programming and Scripting O/P same as on screen Post 302853827 by targetshell on Monday 16th of September 2013 07:22:01 AM
Old 09-16-2013
O/P same as on screen

Code:
#Random Scripts 4
#Desc:
clear
  echo "1. To see all processes currently running on the system"
  echo "2. To kill any given process"
  echo "Choose between the two"
  read x
  case $x in
  "1")print `ps aux`;;
  "2") echo "Choose a process to be killed"
     read y
check=`ps ax | grep $y`
echo $check;;
  *) echo "You selected wrong option";;
esac

Two things :

(1). I need output when the user enters '1' same as we get when we run command "ps ax" on the comand line.

(2). I want to kill a process which user enters in the variable "Y". But the problem I am facing is I am not able to get how to check for the database session.

Code:
amitj:/home/fnb/amitj/scripts1> ps ax |grep isql
 397410 pts/13 A     0:00 grep isql
 495652 pts/15 A     0:00 isql -Utcs2dev -STCSDEV2 -¨ -c -w300

I will enter 'Utcs2dev' as variable in Y but then how to get the process ID from it , and then only I can use kill -9 PID.

Advise !

Last edited by Scott; 09-16-2013 at 09:35 PM.. Reason: Added code tags - 9th time
 

10 More Discussions You Might Find Interesting

1. Programming

How to clear screen

I searched the post and someone said to clear the screen in C, use printf("\033[2J"); ?? However, this doesn't work...typo or no. What is an equivalent command to 'CLS' in DOS/'clear' in UNIX to clear the screen and go to top of screen?? Thank you. (2 Replies)
Discussion started by: giannicello
2 Replies

2. UNIX for Advanced & Expert Users

printing to the screen

HPUX 11.0.X / Korn Shell Hope this makes sense. I have a little function to place things on the screen using the column and row parameters. Question is, how can I be sure of where the current cursor postion is so that if I print something to the upper right hand corner of the screen, I can... (2 Replies)
Discussion started by: google
2 Replies

3. UNIX for Dummies Questions & Answers

reading from a screen

Hi There is a program running which displays output on the screen I have to grep a particular string from that screen how do i do this My problem is i'm running this program from a script which executes after every fifteen mins but sometimes it's happen that there is an error in the program... (4 Replies)
Discussion started by: satyanarayang
4 Replies

4. Linux

Screen on Fedora3

I'm using Fedora3 and Screen when i do that, Scree dont load my Bash profile so my MC, centericq and swedish keyboard is mesed up.. how can i use screen and my bash_profile? or is there another way to fix it? (0 Replies)
Discussion started by: snort
0 Replies

5. UNIX for Dummies Questions & Answers

Double screen

Hi Guys, I'm using a double screen machine with linux Red Hat. The problem is that I see the same image in both screens... Can anybody tell me how to solve this problem? Thanks a lot, Pablo. (0 Replies)
Discussion started by: cordobapablo
0 Replies

6. UNIX for Dummies Questions & Answers

Help with screen

Hello everyone! I'm trying to figure out how to send commands from one screen to another. For example i wish to send a simple "ls -all" from screen #1 to screen #2, can it be done, and how? :confused: Thank you! (12 Replies)
Discussion started by: Gurth
12 Replies

7. OS X (Apple)

Virtual screen accessed by Screen Sharing

Hi, I'm trying to create a virtual screen, (maybe xvfb? or any other virtual screen buffer) and be able to use Screen Sharing to connect to it. The setup is that I have a Mac Mini connected to the TV. But when my girlfriend is using Front Row, I can't use Screen Sharing at the same time from... (0 Replies)
Discussion started by: linge
0 Replies

8. Red Hat

command line tool to disable screen lock and/or screen saver

Hi, I have a simple question : how to disable screen lock and/or sreen saver with command line with RHEL5.4 ? (1 Reply)
Discussion started by: albator1932
1 Replies

9. Red Hat

Black Screen

I am using Intel HD 400 Graphics on a laptop. When I logout, I get a black screen with no cursor or anything. I have to hard reboot the system to get into linux again. Working on RHEL 6 (gnome) (1 Reply)
Discussion started by: sunveer
1 Replies

10. UNIX for Dummies Questions & Answers

Accidentally made a screen within a screen - how to move it up one level?

I made a screen within a screen. Is there a way to move the inner screen up one level so that it is at the same level as the first screen running from the shell? (2 Replies)
Discussion started by: phpchick
2 Replies
KILLALL(1)						    BSD General Commands Manual 						KILLALL(1)

NAME
killall -- kill processes by name SYNOPSIS
killall [-delmsvz] [-help] [-I] [-j jail] [-u user] [-t tty] [-c procname] [-SIGNAL] [procname ...] DESCRIPTION
The killall utility kills processes selected by name, as opposed to the selection by PID as done by kill(1). By default, it will send a TERM signal to all processes with a real UID identical to the caller of killall that match the name procname. The super-user is allowed to kill any process. The options are as follows: -d | -v Be more verbose about what will be done. For a single -d option, a list of the processes that will be sent the signal will be printed, or a message indicating that no matching processes have been found. -e Use the effective user ID instead of the (default) real user ID for matching processes specified with the -u option. -help Give a help on the command usage and exit. -I Request confirmation before attempting to signal each process. -l List the names of the available signals and exit, like in kill(1). -m Match the argument procname as a (case sensitive) regular expression against the names of processes found. CAUTION! This is dangerous, a single dot will match any process running under the real UID of the caller. -s Show only what would be done, but do not send any signal. -SIGNAL Send a different signal instead of the default TERM. The signal may be specified either as a name (with or without a leading ``SIG''), or numerically. -j jail Kill processes in the specified jail. -u user Limit potentially matching processes to those belonging to the specified user. -t tty Limit potentially matching processes to those running on the specified tty. -c procname Limit potentially matching processes to those matching the specified procname. -q Suppress error message if no processes are matched. -z Do not skip zombies. This should not have any effect except to print a few error messages if there are zombie processes that match the specified pattern. ALL PROCESSES
Sending a signal to all processes with the given UID is already supported by kill(1). So use kill(1) for this job (e.g. ``kill -TERM -1'' or as root ``echo kill -TERM -1 | su -m <user>''). IMPLEMENTATION NOTES
This FreeBSD implementation of killall has completely different semantics as compared to the traditional UNIX System V behavior of killall. The latter will kill all processes that the current user is able to kill, and is intended to be used by the system shutdown process only. EXIT STATUS
The killall utility exits 0 if some processes have been found and signalled successfully. Otherwise, a status of 1 will be returned. DIAGNOSTICS
Diagnostic messages will only be printed if requested by -d options. SEE ALSO
kill(1), pkill(1), sysctl(3), jail(8) HISTORY
The killall command appeared in FreeBSD 2.1. It has been modeled after the killall command as available on other platforms. AUTHORS
The killall program was originally written in Perl and was contributed by Wolfram Schneider, this manual page has been written by Jorg Wunsch. The current version of killall was rewritten in C by Peter Wemm using sysctl(3). BSD
June 30, 2013 BSD
All times are GMT -4. The time now is 12:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy