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
logins(1M)																logins(1M)

NAME
logins - display system and user login data SYNOPSIS
groups] logins] DESCRIPTION
displays data concerning system and user logins. The format and content of the output is controlled by command options and may include: system or user login, user ID number, comment field value (for example, user name, location), primary group name, primary group ID, supple- mentary group names, supplementary group IDs, home directory, login shell, user security level, user audit events, and password aging parameters. The default data is: login, user ID, primary group name, primary group ID, and comment field value. Output is sorted by user ID, with user logins following system logins. The default output consists of login, user ID, primary group, primary group ID and comment field formatted into columns. The following options are available to this command: Display two account expiration fields. The fields show how long the account can be unused (in days) before it becomes inactive and the date the account will expire. Display logins with duplicate UIDs. Show multiple group membership data. Display with alternate format of one line of colon separated fields. Display logins with no passwords Display all system logins Sort output by login rather than UID. Display all user logins. Display extended information about selected users. This extended information includes home directory, login shell and password aging data, each on its own line. Password information consists of pass- word status (PS for valid password, LK for locked and NP for no password) and, if a password is present, date of last change, required number of days between changes, and number of days allowed between changes. In the case of non-trusted systems, the date of last change will be the latest Thursday since the change. Display all users belonging to groups, sorted by login. A comma separated list specifies multiple groups. Display the requested logins. A comma separated list specifies multiple logins. Specify a switch used to classify NIS or local users. With the option, only users belonging to the specified repository are displayed. Multiple options may be used. Any login matching any of the criteria will be displayed. A login will be displayed only once, even if it meets multiple criteria. EXAMPLES
List all logins in default format. List all logins that have no password or have a duplicate UID in default format. List all system logins in the alternate format. List all local users of the system. List all the NIS users of the system. WARNINGS
HP-UX 11i Version 3 is the last release to support trusted systems functionality. FILES
HP-UX password file. HP-UX group file. SEE ALSO
listusers(1), passwd(1), group(4), passwd(4), prpwd(4), shadow(4). STANDARDS CONFORMANCE
logins(1M)
All times are GMT -4. The time now is 01:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy