Sponsored Content
Top Forums Shell Programming and Scripting Trying to kill a program via help command. Post 302187782 by TiznaraN on Tuesday 22nd of April 2008 03:29:43 AM
Old 04-22-2008
-aux errors for me, here's what I have now

ps | awk ' /program/ {print $1} '

This is outputting the PID, isn't there a way to store the number in a variable rather than print it, maybe then pipe it into a kill? I'm not sure of the syntax I guess.

edit: I meant to say via exit command in the title. Smilie

edit2: no longer relevant

edit3: break; I gotta start dumbing myself down, or reading more before trying to code.

But, pretend this was to do something other than break a loop., Let's say I am trying to find out how many times someone has logged into the machine. Use last to display all the different logins, several names pop up, some multiple times. This is something else I was working on, all I can figure out is the total number of logins, but I can't determine how to compare if $1(user name) is there more than once, and ontop of that count it if it is.

ex.

toyoung
rasmith
toyoung

output i'm looking for would be

toyoung 2
rasmith 1

here's what i have:

last | awk ' END {print "Number of logins:", NR} '

Last edited by TiznaraN; 04-22-2008 at 04:57 AM..
 

10 More Discussions You Might Find Interesting

1. Programming

C program to kill root processes

Hello, First let me start by saying I have searched the forum and read all the SUID stuff but it is not in the neighborhood I am looking for. Here is the problem. We want to grant a non super-user permission to kill root processes but only if the process matches certain criteria. ... (8 Replies)
Discussion started by: TioTony
8 Replies

2. Programming

kill textrdit program

Dear All: I use sun OS system and write a code in c as folloing purpose kill textedit program,but i get some error please give me a great help Thanks. #include <stdlib.h> int main() { const char cTestPrag=" kill -9 `ps -ef | grep textedit | grep -v "grep"| awk '{print $2}'| xargs` "; ... (6 Replies)
Discussion started by: jeter
6 Replies

3. Shell Programming and Scripting

kill multiple instances of the same program

Hi, I know that the answer to this is very simple, since I saw somebody do it some time back..but I forgot how. The problem is, I have multiple instances of the same program running simultaneously and I want to kill them all in a single command. I know that it can be done using awk '{print... (12 Replies)
Discussion started by: ipzig
12 Replies

4. Shell Programming and Scripting

Kill a process without using kill command

Sorry, posted the question in other forum. (0 Replies)
Discussion started by: sudhamacs
0 Replies

5. Linux

Kill a process without using kill command

I want to Kill a process without using kill command as i don't have privileges to kill the process. I know the pid and i am using Linux 2.6.9 OS. (6 Replies)
Discussion started by: sudhamacs
6 Replies

6. UNIX for Dummies Questions & Answers

Script to open program and send/execute command in program

Hi, i want to write a script that executes a program (exec?) . this program then requires a filename as input. how do i give it this input in the script so the program will be complete run and close by the script. e.g. exec prog.exe program then asks for filename "enter filename:"... (1 Reply)
Discussion started by: tuathan
1 Replies

7. Shell Programming and Scripting

Kill the running program

Dear All, I have a script which after executing is not stoping when i press ctrl+c. Now i want to Append the script in such a way when i press ctrl+c while execution of the program it should take it as arguements and should kill the script/running program forcefully. I know the command to... (1 Reply)
Discussion started by: akhtar.bhat
1 Replies

8. Shell Programming and Scripting

Kill shell script when host program not running/disk unmounted

I have my Mac OS X program executing a shell script (a script that copies files to a drive). I want to make it so that the shell script automatically kills itself if it finds that the host .app is not running OR kill itself if the drive that it is copying files to has been unmounted. Right now what... (2 Replies)
Discussion started by: pcwiz
2 Replies

9. UNIX for Dummies Questions & Answers

Kill a running program?

Hello i'm trying to make a program which can find a running program on the system and kill it, then repeat that every 5 minutes. The name of the process is given with an argument. I have done this so far, but still not working. if $1 in $(ps -e) ; then kill $(pidof $1) sleep 5m fi (3 Replies)
Discussion started by: petel1
3 Replies

10. UNIX for Dummies Questions & Answers

Kill a program from bash

to kill a program in bash, for instance 'mousepad' I use kill $(pidof mousepad); or pkill mousepad But it only works if we use another bash window; If it is started from the same bash, that does not work: #mousepad;kill $(pidof mousepad); In this case, it looks like mousepad hangs... (7 Replies)
Discussion started by: arpagon
7 Replies
listusers(1)							   User Commands						      listusers(1)

NAME
listusers - list user login information SYNOPSIS
listusers [-g groups] [-l logins] DESCRIPTION
Executed without any options, this command lists all user logins sorted by login. The output shows the login ID and the account field value from the system's password database as specified by /etc/nsswitch.conf. OPTIONS
The following options are supported: -g groups Lists all user logins belonging to group, sorted by login. Multiple groups can be specified as a comma-separated list. -l logins Lists the user login or logins specified by logins, sorted by login. Multiple logins can be specified as a comma-separated list. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
nsswitch.conf(4), attributes(5) NOTES
A user login is one that has a UID of 100 or greater. The -l and -g options can be combined. User logins will only be listed once, even if they belong to more than one of the selected groups. SunOS 5.10 18 Mar 1994 listusers(1)
All times are GMT -4. The time now is 12:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy