01-03-2006
If and Or Condition in Unix [ksh]
I have the code below. I want to said
If TrackErrors > 0 or count == 0
then
MailErrors
else
MailSuccess
fi.
if [ ${trackErrors} -gt 0 || ${count} -eq 0 ]
then
MailErrors ${count}
else
MailSuccess ${count}
fi
Any helps greatly appreciated.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hey guyes!
i have a little problem in if condition, can anybody please solve my problem?
Here what i am doing.
if
then
echo "int1 is equal to int2"
elif
then
echo "int1 is greater than int2"
else
echo "int1 is smaller than int2"
fiNo, matter int1 is smaller than... (9 Replies)
Discussion started by: abidmalik
9 Replies
2. Shell Programming and Scripting
Dear All,
Please advice about this issue.
when i run this line in a script if && || && || && if i enter $x = test3 and $y = test1 the If condition apply while it should not
Best Regards (2 Replies)
Discussion started by: islam.said
2 Replies
3. Shell Programming and Scripting
The syntax of 'if' conditionals in bash and ksh seems different. I am trying to check for a particular version using 'if' in ksh. This very simple syntax gives syntax error. I have tried many variants, but no go. Please correct the syntax. Later I will expand it to 'if' and 'else'.
#!/bin/ksh... (8 Replies)
Discussion started by: nivedhitha
8 Replies
4. Shell Programming and Scripting
I'm having an issue using OR condition, the script seems to work just fine but gives an error message while executing as can be seen in BOLD RED below:
Code:
#cat test.sh
#!/bin/ksh
set -x
if || > /dev/null 2>&1;then
echo "Fibre adapter found"
else
echo "No fibre... (10 Replies)
Discussion started by: mbak
10 Replies
5. Shell Programming and Scripting
Hi ,
I'm a newbie.Never worked on Unix before. I want a shell script to perform the following:
I want to extract strings from each line ,based on the type of line(Nameline,Subline) and output it to another file.Below is a sample format.
2010-12-21 14:00"1"Nameline"Midterm"First Name:Jane ... (4 Replies)
Discussion started by: angie1234
4 Replies
6. UNIX for Dummies Questions & Answers
in my code if condition is not working.
i am using array in the if condition
the code:
set -A rt 0 1 7 13 21
echo "Please enter a choice"
read choice;
for i in 0 1 2 3 4
do
if }]
then
echo "something"
fi
done (6 Replies)
Discussion started by: jeanzibbin
6 Replies
7. Shell Programming and Scripting
I want to know the if condition in checking the hostname in unix and then running a cron job (all in a single line)
Thanks (2 Replies)
Discussion started by: prash358
2 Replies
8. Shell Programming and Scripting
i have a script where i have to find the age of a file,
if
then
echo "dnb file is present for the monthly load" >> $RUNLOG
dnb="1"
else
echo "dnb file has not arrived yet" > $ERRLOG
dnb="0"
fi
i know the file is available so... (3 Replies)
Discussion started by: lovelysethii
3 Replies
9. Shell Programming and Scripting
Hi
I am trying to do a "IF" Condition in UNIX where we compare EACH file size in a directory with a SIZE (Parameter passed)
If Each File size EXCEEDS parameter passed SIZE then we manipulate the file.
Somehow the IF condition do not work ?? (is this Variable decalration issue ??)
... (9 Replies)
Discussion started by: Pete.kriya
9 Replies
10. Shell Programming and Scripting
I want to build an Errorlog. I would like to build an array as I move through the if statements and print the array once all error conditions have been defined. The results need to be comma delimited.
tsver will be static "1.9.6(2)"
other vars $prit $lt $rt can have the same or a different... (1 Reply)
Discussion started by: popeye
1 Replies
LEARN ABOUT OPENSOLARIS
_lwp_sema_init
_lwp_sema_wait(2) System Calls _lwp_sema_wait(2)
NAME
_lwp_sema_wait, _lwp_sema_trywait, _lwp_sema_init, _lwp_sema_post - semaphore operations
SYNOPSIS
#include <sys/lwp.h>
int _lwp_sema_wait(lwp_sema_t *sema);
int _lwp_sema_trywait(lwp_sema_t *sema);
int _lwp_sema_init(lwp_sema_t *sema, int count);
int _lwp_sema_post(lwp_sema_t *sema);
DESCRIPTION
Conceptually, a semaphore is an non-negative integer count that is atomically incremented and decremented. Typically this represents the
number of resources available. The _lwp_sema_init() function initializes the count, _lwp_sema_post() atomically increments the count, and
_lwp_sema_wait() waits for the count to become greater than 0 and then atomically decrements it.
LWP semaphores must be initialized before use. The _lwp_sema_init() function initializes the count associated with the LWP semaphore
pointed to by sema to count.
The _lwp_sema_wait() function blocks the calling LWP until the semaphore count becomes greater than 0 and then atomically decrements it.
The _lwp_sema_trywait() function atomically decrements the count if it is greater than zero. Otherwise it returns an error.
The _lwp_sema_post() function atomically increments the semaphore count. If there are any LWPs blocked on the semaphore, one is unblocked.
RETURN VALUES
Upon successful completion, 0 is returned. A non-zero value indicates an error.
ERRORS
The _lwp_sema_init(), _lwp_sema_trywait(), _lwp_sema_wait(), and _lwp_sema_post() functions will fail if:
EINVAL The sema argument points to an invalid semaphore.
EFAULT The sema argument points to an illegal address.
The _lwp_sema_wait() function will fail if:
EINTR The function execution was interrupted by a signal or fork(2).
The _lwp_sema_trywait() function will fail if:
EBUSY The function was called on a semaphore with a zero count.
The _lwp_sema_post() function will fail if:
EOVERFLOW The value of the sema argument exceeds SEM_VALUE_MAX.
SEE ALSO
fork(2)
SunOS 5.11 8 May 1998 _lwp_sema_wait(2)