Sponsored Content
Full Discussion: O/P same as on screen
Top Forums Shell Programming and Scripting O/P same as on screen Post 302854113 by Smiling Dragon on Monday 16th of September 2013 06:16:12 PM
Old 09-16-2013
(1) Replace "print `blahblah`" with "blahblah", the backtick (`) is really only useful for storing outputs in variables and using them embedded in other commandlines, if you just want to print the result direct to the screen and nothing else, you don't need them.
eg
Code:
case $x in
"1") ps aux;;
"2") echo "Choose a process to be killed"

(2) You could use killall to do what you want here but I dislike it as it can do horribly wrong on you if you are not careful.
Code:
PIDSIWANTTOKILL=`ps -eo pid,args | awk "/$THINGTOSEARCHFOR/ { print \$1 }"`

Note that if the user puts something silly (like "a" for example) in the THINGIWANTOSEARCHFOR variable, many many many pids can end up in the resultant list.
 

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
PIDOF(8)						Linux System Administrator's Manual						  PIDOF(8)

NAME
pidof -- find the process ID of a running program. SYNOPSIS
pidof [-s] [-c] [-n] [-x] [-o omitpid[,omitpid..]] [-o omitpid[,omitpid..]..] program [program..] DESCRIPTION
Pidof finds the process id's (pids) of the named programs. It prints those id's on the standard output. This program is on some systems used in run-level change scripts, especially when the system has a System-V like rc structure. In that case these scripts are located in /etc/rc?.d, where ? is the runlevel. If the system has a start-stop-daemon (8) program that should be used instead. OPTIONS
-s Single shot - this instructs the program to only return one pid. -c Only return process ids that are running with the same root directory. This option is ignored for non-root users, as they will be unable to check the current root directory of processes they do not own. -n Avoid stat(2) system function call on all binaries which are located on network based file systems like NFS. Instead of using this option the the variable PIDOF_NETFS may be set and exported. -x Scripts too - this causes the program to also return process id's of shells running the named scripts. -o omitpid Tells pidof to omit processes with that process id. The special pid %PPID can be used to name the parent process of the pidof pro- gram, in other words the calling shell or shell script. EXIT STATUS
0 At least one program was found with the requested name. 1 No program was found with the requested name. NOTES
pidof is actually the same program as killall5; the program behaves according to the name under which it is called. When pidof is invoked with a full pathname to the program it should find the pid of, it is reasonably safe. Otherwise it is possible that it returns pids of running programs that happen to have the same name as the program you're after but are actually other programs. Note that that the executable name of running processes is calculated with readlink(2), so symbolic links to executables will also match. SEE ALSO
shutdown(8), init(8), halt(8), reboot(8), killall5(8) AUTHOR
Miquel van Smoorenburg, miquels@cistron.nl 01 Sep 1998 PIDOF(8)
All times are GMT -4. The time now is 04:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy