06-10-2005
try ... in ksh ...
[ $email ] && do_something
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am making a script to check the parameters, but it seems that I can't catch the parameters by loop.
$ cat sendmsg.sh
#!/bin/sh
## Parameter Check
i=0
max=$#
while
do
PARAM=$${i}
i=`expr ${i} + 1`
echo ${PARAM}
done
How can I get the $1, $2, $3 by loop and set their... (2 Replies)
Discussion started by: GCTEII
2 Replies
2. Shell Programming and Scripting
Hi Guys,
I am writing a Unix script which accepts a directory path as parameter $1
so something like
/user5.data/WA/01
will be passed in.
I want to determine if the directory path passed in contains "WA" as above (because then I need to do something specific if it does)
What is the... (9 Replies)
Discussion started by: bcunney
9 Replies
3. Shell Programming and Scripting
HI all,
I have a parameter file with entries like
$$Name =Abhinav
$$CUTOFF_DATE = 11/11/2209
I am reading a variable from this file using a awk command like :
var2=`awk -F"" "/CUTOFF_DATE/{f=$1;}{print f;}" InputFIleName`
but facing an error like
awk: cmd. line:1:... (3 Replies)
Discussion started by: abhinav192
3 Replies
4. UNIX for Advanced & Expert Users
Hi all,
I have four (4) different UNIX flavours and I want to know whether the following commands are correct with respect to wanting to check on what are my current kernel parameter settings.
I just want to clear the doubts hanging over my head whether the commands below are the right ones... (2 Replies)
Discussion started by: newbie_01
2 Replies
5. Shell Programming and Scripting
Hi all
i need to check that if user has passed any input parameter while executing he shell script like
./test1.sh -a"-v"
then do smothing
if user execute the script without giving input paramater then
./test1.sh
then do something
how can we check this input parameter (6 Replies)
Discussion started by: aishsimplesweet
6 Replies
6. Shell Programming and Scripting
Hello again :)
Am currently trying to write a function which will delete a record from a file.
The code currently looks as such:
function deleteRecord() {
clear
read -p "Please enter the ID of the record you wish to remove: " strID
... (2 Replies)
Discussion started by: U_C_Dispatj
2 Replies
7. Shell Programming and Scripting
Hey I'm new in linux,
I'm looking for a code to check whether the parameter is a number or a string.
I have already tried this code:
eerste=$(echo $1 | grep "^*$">aux)
if
But it doesn't work.:confused:
Thanks (2 Replies)
Discussion started by: Eclecticaa
2 Replies
8. Shell Programming and Scripting
Hi,
In my script, there is a variable as below
TME=`date +%H`
I want to take this TME value into another variable called TME_PAR which i can use outside of the current script and this TME_PAR is already present in my home_dir and i wrote below line of code
$home_dir/$TME_PAR=`echo... (1 Reply)
Discussion started by: JSKOBS
1 Replies
9. Shell Programming and Scripting
I have a code which is using to find duplicates in a files based on column.Below is the same code which is used to find duplicates in my file based on column 1
awk -F'|' '{if (x) { x_count++; print $0; if (x_count == 1) { print x } } x = $0}' FileName >Dup_File.txt
But my requirement here is... (3 Replies)
Discussion started by: ginrkf
3 Replies
10. Shell Programming and Scripting
Hi
I am trying to understand a shell scipt file ( .ksh file ) . In the shell script we are referring a variable .
Example : SessLogs=$STAFF_MSTR_DIR/staff_dtls
There are no references in the shell script from where the variable "$STAFF_MSTR_DIR" is being read from .
Could anyone... (2 Replies)
Discussion started by: Sudheer Maddula
2 Replies
LEARN ABOUT DEBIAN
perl::critic::policy::controlstructures::prohibitpostfixcontrols
Perl::Critic::Policy::ControlStructures::ProhibitPostfixUserrContributed PerlPerl::Critic::Policy::ControlStructures::ProhibitPostfixControls(3pm)
NAME
Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls - Write "if($condition){ do_something() }" instead of "do_something() if
$condition".
AFFILIATION
This Policy is part of the core Perl::Critic distribution.
DESCRIPTION
Conway discourages using postfix control structures ("if", "for", "unless", "until", "when", "while") because they hide control flow. The
"unless" and "until" controls are particularly evil because they lead to double-negatives that are hard to comprehend. The only tolerable
usage of a postfix "if"/"when" is when it follows a loop break such as "last", "next", "redo", or "continue".
do_something() if $condition; # not ok
if ($condition) { do_something() } # ok
do_something() while $condition; # not ok
while ($condition) { do_something() } # ok
do_something() unless $condition; # not ok
do_something() unless ! $condition; # really bad
if (! $condition) { do_something() } # ok
do_something() until $condition; # not ok
do_something() until ! $condition; # really bad
while (! $condition) { do_something() } # ok
do_something($_) for @list; # not ok
LOOP:
for my $n (0..100) {
next if $condition; # ok
last LOOP if $other_condition; # also ok
next when m< 0 z >xms; # fine too
}
CONFIGURATION
A set of constructs to be ignored by this policy can specified by giving a value for 'allow' of a string of space-delimited keywords: "if",
"for", "unless", "until", "when", and/or "while". An example of specifying allowed flow-control structures in a .perlcriticrc file:
[ControlStructures::ProhibitPostfixControls]
allow = for if until
By default, all postfix control keywords are prohibited.
The set of flow-control functions that are exempt from the restriction can also be configured with the 'flowcontrol' directive in your
.perlcriticrc file:
[ControlStructures::ProhibitPostfixControls]
flowcontrol = warn die carp croak cluck confess goto exit
This is useful if you're using additional modules that add things like "assert" or "throw".
NOTES
The "die", "croak", and "confess" functions are frequently used as flow-controls just like "next" or "last". So this Policy does permit
you to use a postfix "if" when the statement begins with one of those functions. It is also pretty common to use "warn", "carp", and
"cluck" with a postfix "if", so those are allowed too.
The "when" keyword was added to the language after Perl Best Practices was written. This policy treats "when" the same way it does "if",
i.e. it's allowed after flow-control constructs. Thanks to brian d foy for the inspiration
<http://www.effectiveperlprogramming.com/blog/543>.
BUGS
Look for the "do {} while" case and change the explanation to point to page 123 when it is found. RT #37905.
AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license
can be found in the LICENSE file included with this module.
perl v5.14.2 2012-06-0Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls(3pm)