03-15-2011
Thaks hergp, that is what I am looking for.. I was wondering what makes my code fail, now I found answer for it.
Short-cut syntax for 'if' construct is really very un-safe and does not replace standard structure. God forbid a un-expected issue makes your last statement in if condition fail, it would cause control go into else part. If its doing a critical work in Production, you will go nuts as to what hit this logic :-)!
Does any one dispute my conclusions? If not stop using short-cut 'if' construct in business critical programs..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
Has been a while since I was last on, so I hope everyone has been doing fine. ;)
Would like to know if the below IF statement syntax is correct for a ksh environment. It's been pushed into live as someone had deleted the development copy(!); not withstanding that, the statement now... (3 Replies)
Discussion started by: Cameron
3 Replies
2. Shell Programming and Scripting
Hi,
Can you please help me with this one: I write an "if" statement, something like this:
if
then
echo "big file"
else
echo "normal file"
and I get an error: `'then is not expected
Thanks in advance (6 Replies)
Discussion started by: apenkov
6 Replies
3. Shell Programming and Scripting
Hi there
I am trying to write an if statement in perl that will return "SUCCESS" if either of these conditions are true
a) if $changes is greater than 5 AND the $force flag is set to 1
OR
b) if $changes is greater than 0 AND $changes is less than 6
#!/usr/bin/perl -w
my $force =... (5 Replies)
Discussion started by: rethink
5 Replies
4. UNIX for Dummies Questions & Answers
Hi, can someone please tell me what is wrong with this code? I just want it to check if the file size is greater than 2000kb.
if
Thanks!
---------- Post updated at 09:23 PM ---------- Previous update was at 09:21 PM ----------
I should probably post the full code:
#!/bin/sh... (9 Replies)
Discussion started by: Bengel
9 Replies
5. UNIX for Dummies Questions & Answers
can anyone please explain my below statement, i am confused.
if || \
|| \
|| \
||
then (1 Reply)
Discussion started by: kd09714
1 Replies
6. Shell Programming and Scripting
I have following requirement.
Say, my text file contains following patterns
{2010501005|XXGpvertex|9|0|17|0|{|{30100001|XXparameter_set|@@@@{{30001002|XXparameter|!prototype_path|$AB_COMPONENTS/Sort/Sort.mpc|3|2|Pf$|@{0|}}
}}@0|@315000|78500|335000|99000|114000|87000|17|And the Sort|Ab... (8 Replies)
Discussion started by: Shell_Learner
8 Replies
7. UNIX for Advanced & Expert Users
I need to modify the find command below to exclude the output of the directory /usr/UDPM/PerfMgmt/shmlck
find / \( -fstype ctfs -o -fstype mntfs -o -fstype objfs -o -fstype proc -o ! local \) -prune -o -type f -perm -0002 -print 2>/dev/null
I have tried many iterations and placement of... (2 Replies)
Discussion started by: interesting?
2 Replies
8. Shell Programming and Scripting
Hi,
Is there a way to compare the value in if condition with a list of values.
eg . if ]
then
echo "it's a mammal"
else
echo "its not"
fi
Thanks! (8 Replies)
Discussion started by: neil.k
8 Replies
9. Shell Programming and Scripting
Hi,
In short : I have several log files and I need to find the last file with a certain keyword in it.
# ls -1tr logs
log_hostX.Jan01_0100.gz
log_hostX.Jan01_0105.gz
log_hostX.Jan01_0110.gz
log_hostX.Jan01_0115.gz
log_hostX.Jan01_0120.gz
log_hostX.Jan01_0125.gz
log_hostX.Jan01_0130.gz... (2 Replies)
Discussion started by: ejdv
2 Replies
10. UNIX for Beginners Questions & Answers
I'm new to unix and the command line and am trying to learn different commands. I have a file (teledir.txt) that contains a name and phone number for 3 different people. I am writing a script that is to take two positional parameters and I typed out how it should behave:
if <name and number... (1 Reply)
Discussion started by: Eric7giants
1 Replies
LEARN ABOUT FREEBSD
critical
CRITICAL_ENTER(9) BSD Kernel Developer's Manual CRITICAL_ENTER(9)
NAME
critical_enter, critical_exit -- enter and exit a critical region
SYNOPSIS
#include <sys/param.h>
#include <sys/systm.h>
void
critical_enter(void);
void
critical_exit(void);
DESCRIPTION
These functions are used to prevent preemption in a critical region of code. All that is guaranteed is that the thread currently executing
on a CPU will not be preempted. Specifically, a thread in a critical region will not migrate to another CPU while it is in a critical
region. The current CPU may still trigger faults and exceptions during a critical section; however, these faults are usually fatal.
The critical_enter() and critical_exit() functions manage a per-thread counter to handle nested critical sections. If a thread is made
runnable that would normally preempt the current thread while the current thread is in a critical section, then the preemption will be
deferred until the current thread exits the outermost critical section.
Note that these functions are not required to provide any inter-CPU synchronization, data protection, or memory ordering guarantees and thus
should not be used to protect shared data structures.
These functions should be used with care as an infinite loop within a critical region will deadlock the CPU. Also, they should not be inter-
locked with operations on mutexes, sx locks, semaphores, or other synchronization primitives. One exception to this is that spin mutexes
include a critical section, so in certain cases critical sections may be interlocked with spin mutexes.
HISTORY
These functions were introduced in FreeBSD 5.0.
BSD
October 5, 2005 BSD