Sponsored Content
Top Forums Shell Programming and Scripting Why do I need this in the script tutorial? Post 302529951 by alister on Saturday 11th of June 2011 03:27:26 PM
Old 06-11-2011
Better still, use pgrep/pkill. They may not be universal, but they're not rare either. A lot of systems have them.

If not, your ps probably has a way to modify its output format to only include the command's name in the output (argv[0]). This way, you don't have to defend against command line arguments colliding with command names (or user names, or group names, or ... you get the picture).

Linux's ps seems to have a -C option for filtering on command name, which could also be of use. But, if using Linux, pgrep is almost certainly available.

From Man Page for ps (Linux Section 1) - The UNIX and Linux Forums
Quote:
Print only the process IDs of syslogd:

ps -C syslogd -o pid=
Sadly, ps is one of those commands that is not at all portable. ps on a *BSD system and ps on a linux box and ps on one of the commercial unices tend to require different arguments for everthing but the most trivial invocations.

Regards,
Alister
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Procmail Tutorial

Hello, Somebody knows a good procmail tutorial in the net? Thanks!:) (1 Reply)
Discussion started by: luiz_fer10
1 Replies

2. UNIX for Dummies Questions & Answers

Unix Tutorial

Any good UNIX tutorials to download? Any good APACHE tutorials? thanks (2 Replies)
Discussion started by: TEKGALAHAD
2 Replies

3. Shell Programming and Scripting

Tk tutorial

Anyone know any good website with a step by step instructions on writing Perl GUI scripts with Tk ??? (3 Replies)
Discussion started by: perleo
3 Replies

4. Post Here to Contact Site Administrators and Moderators

Tutorial forum?

I got this account a while ago and didn't have much time to try it out. After having had some frustration by posting tutorials regarding various Linux activites of mine in my Slashdot journals, it occurred to me that this forum might be better suited. I know I can probably post in the OS specific... (1 Reply)
Discussion started by: deckard
1 Replies

5. IP Networking

RouterSim tutorial.

Hi everyone... Well, this is a kina of help tutorial question. I'm using actually the “RouterSim Network Visualizer” an environment where you can practice and create your own LAN, I will be honest, I'm new to creating and managing networks, but not to new about IP´s. So, the question, anyone... (0 Replies)
Discussion started by: TARFU
0 Replies

6. Shell Programming and Scripting

Shell script tutorial?

Hi All, I have started preparation of Shell script...Can anybody send me the link where I can get a right tutorial or pdf file of shell script... Thanks in Advance (2 Replies)
Discussion started by: kunalpatil09
2 Replies

7. AIX

AIX useful tutorial...

hi guys, I want to learn AIX, I am a beginner for this operating system of IBM. Can anyone give me some useful tutorial for a beginner like me?... Thanks... + GOD bless + ^_^ (1 Reply)
Discussion started by: TechReader
1 Replies

8. Solaris

Need LAMP tutorial!

Hello Everybody, Does anybody know or recommend me a tutorial for LAMP server on Solaris 10 x86? (3 Replies)
Discussion started by: ahmedamer12
3 Replies

9. Web Development

Vue JS 2 Tutorial by The Net Ninja: A Recommended Vue.js Video Tutorial Series

A number of people have asked me how to get started with Vue.js and my reply before today was to Google "Vue.js". That has changed and my recommendation to anyone who wants to learn the fastest growing, easiest to learn and use Vue.js web dev framework is to watch this video tutorial series: ... (0 Replies)
Discussion started by: Neo
0 Replies
libcaca-tutorial(3caca) 					      libcaca						   libcaca-tutorial(3caca)

NAME
libcaca-tutorial - A libcaca tutorial First, a very simple working program, to check for basic libcaca functionalities. #include <caca.h> int main(void) { caca_canvas_t *cv; caca_display_t *dp; caca_event_t ev; dp = caca_create_display(NULL); if(!dp) return 1; cv = caca_get_canvas(dp); caca_set_display_title(dp, 'Hello!'); caca_set_color_ansi(cv, CACA_BLACK, CACA_WHITE); caca_put_str(cv, 0, 0, 'This is a message'); caca_refresh_display(dp); caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1); caca_free_display(dp); return 0; } What does it do? o Create a display. Physically, the display is either a window or a context in a terminal (ncurses, slang) or even the whole screen (VGA). o Get the display's associated canvas. A canvas is the surface where everything happens: writing characters, sprites, strings, images... It is unavoidable. Here the size of the canvas is set by the display. o Set the display's window name (only available in windowed displays, does nothing otherwise). o Set the current canvas colours to black background and white foreground. o Write the string 'This is a message' onto the canvas, using the current colour pair. o Refresh the display, causing the text to be effectively displayed. o Wait for an event of type CACA_EVENT_KEY_PRESS. o Free the display (release memory). Since it was created together with the display, the canvas will be automatically freed as well. You can then compile this code on an UNIX-like system using the following commans (requiring pkg-config and gcc): gcc `pkg-config --libs --cflags caca` example.c -o example Version 0.99.beta18 Fri Apr 6 2012 libcaca-tutorial(3caca)
All times are GMT -4. The time now is 01:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy