Sponsored Content
Full Discussion: If condition help required
Top Forums Shell Programming and Scripting If condition help required Post 302851919 by krishmaths on Tuesday 10th of September 2013 04:54:37 AM
Old 09-10-2013
Code:
x=$(ps -fu myuserid | grep [j]ava | awk '{print $2}')
if [ ! -z $x ]
then
  echo process is running
else
  echo process not running
fi

This User Gave Thanks to krishmaths For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

help required

hi i am new to c programming and found this on the net could someone tell me what it actually does, many thanks in advance cheers #include <fcntl.h> main() { int fd; fd = open("in1", O_RDONLY); printf("%d\n", fd); } and this too please #include <fcntl.h> main() { int... (1 Reply)
Discussion started by: ruffenator
1 Replies

2. UNIX for Dummies Questions & Answers

help required

Hi All, Please help me in the following query need a command to get all the files in the present directory except the next day file format :: abc_<DD>.log $ls -l abc_10.log abc_10.log abc_11.log Now i need the output in abc.list which should contains $more abc.list abc_10.log... (5 Replies)
Discussion started by: thaduka
5 Replies

3. Shell Programming and Scripting

End of loop condition required???

Hi i have a variable with lots of tokens seperated with spaces. e.g VAR="ABC DEF GHSD GHQS TUTSD JHDTQ QDHQ CDQKDGQ WQUTQD DQUTQD DQJGDQ QDTQD WDQUTQDU QDUGQD QDJGQD DQUTDUQ QDUIDTQ" i want to separate all of the above tokens and call a script with each of the token e.g sh script.sh <TOKEN>... (4 Replies)
Discussion started by: skyineyes
4 Replies

4. Shell Programming and Scripting

Please Help required.

Hello guys I am new to awk programming. I need the below required script which can perform the following. I have a file containing below data. SNA NoCRD = 131 SNA OBarr = 3 SNC NoCRD = 76 SNC OBarr = 1 SND NoCRD = 155 SND OBarr = 5 SNE NoCRD = 100 SNE OBarr = 1 SNF NoCRD = 131 SNF... (2 Replies)
Discussion started by: jurial
2 Replies

5. Shell Programming and Scripting

Help Required

Below is my code which gives output like this: Every time we have to open the script file and change the value of TG in BEGIN. what i want to do is that i give two three values at the sametime and then run the script and it gives output one by one at the same time. I think i have to define... (2 Replies)
Discussion started by: wakhan
2 Replies

6. Shell Programming and Scripting

Getting required fields from a test file in required fromat in unix

My data is something like shown below. date1 date2 aaa bbbb ccccc date3 date4 dddd eeeeeee ffffffffff ggggg hh I want the output like this date1date2 aaa eeeeee I serached in the forum but didn't find the exact matching solution. Please help. (7 Replies)
Discussion started by: rdhanek
7 Replies

7. HP-UX

Difference between [condition] and [[condition]] and ((condition)) when used with if condition

Executed the following if conditions .. and got different results . only (( )) gave correct o/p with all scenarios . Can anybody please let me know what is the difference between and ] and ((condition)) when used with if condition. And why each condition gave different result. 1.... (2 Replies)
Discussion started by: soumyabubun
2 Replies

8. Shell Programming and Scripting

redirect stdout echo command in condition A run in condition B

hi, I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command Here are my simple script After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Discussion started by: jao_madn
3 Replies

9. Shell Programming and Scripting

Help with extract info if fulfill condition required

Input file (4 DATA record shown in this case): DATA AA0110 ACCESSION AA0110 VERSION AA0110 GI:157412239 FEATURES Location/Qualifiers length 1..1170 1..1700 /length="1170" position ... (5 Replies)
Discussion started by: perl_beginner
5 Replies

10. Shell Programming and Scripting

If condition return 0 even when it fails to satisfy te condition

HI My doubt may be basic one but I need to get it clarified.. When i use "if" condition that checks for many AND, OR logical conditions like if ]; then return 0 fi Even the if condition fails it returns as zero.. Any clue.. But if i add else condition like if ]; ... (2 Replies)
Discussion started by: Priya Amaresh
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 06:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy