Sponsored Content
Top Forums Shell Programming and Scripting simple if/then issue in korn shell Post 302357830 by Scott on Wednesday 30th of September 2009 06:07:39 PM
Old 09-30-2009
There's something to be said for both [[ ... ]] and && || and something against.

Code:
/root/tmp # [[ Y = Y ]] && paaa y || echo b
-ksh: paaa: not found [No such file or directory]
b

Personally I prefer [ ... ] and quotes where needed, and an if [ ... ]; then else where the && part could itself fail.

[[ ]] is testing the test, and leaves you not knowing necessarily why the inner test failed. Was the condition false? Was the variable not declared when it should have been?

Just a preference.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

KORN Shell - Spawn new shell with commands

I want to be able to run a script on one server, that will spawn another shell which runs some commands on another server.. I have seen some code that may help - but I cant get it working as below: spawn /usr/bin/ksh send "telnet x <port_no>\r" expect "Enter command: " send "LOGIN:x:x;... (2 Replies)
Discussion started by: frustrated1
2 Replies

2. Shell Programming and Scripting

how to convert from korn shell to normal shell with this code?

well i have this code here..and it works fine in kornshell.. #!/bin/ksh home=c:/..../ input=$1 sed '1,3d' $input > $1.out line="" cat $1.out | while read a do line="$line $a" done echo $line > $1 rm $1.out however...now i want it just in normal sh mode..how to convert this?... (21 Replies)
Discussion started by: forevercalz
21 Replies

3. Shell Programming and Scripting

Unix Korn Shell Array Issue (SunOS)

Hello, I'm currently messing around with arrays for the first time in scripting (Unix Korn Shell). All I'm trying to do right now before I make things complicated is read through and print out to screen whether the read file is or is not a directory. Here is my directory: ls -l total... (5 Replies)
Discussion started by: Janus
5 Replies

4. Shell Programming and Scripting

help with simple korn scripting

Hi, The logic is very simple but I can't seem to make this work in Korn shell. I need to check two files to make sure there is no errors. Each of the file will have number. For example, first file btt.txt will have 112 which is good. Second file bgg.txt will have 6 which is also good. If I... (4 Replies)
Discussion started by: samnyc
4 Replies

5. Shell Programming and Scripting

Question about a simple Korn script

Hi to everybody! I want to write a simple script in ksh that decrypts and encrypts using the DES algorithm. There is no builtin function in UNIX : i have found only a function in openssl but i don't understand how to use it. The script must accept in input the plaitext and the DESKEY in... (2 Replies)
Discussion started by: kazikamuntu
2 Replies

6. Shell Programming and Scripting

How to activate Korn Shell functionnalities in Bourne Shell

Hi All I have writing a Korn Shell script to execute it on many of our servers. But some servers don't have Korn Shell installed, they use Borne Shell. Some operations like calculation don't work : cat ${file1} | tail -$((${num1}-${num2})) > ${file2} Is it possible to activate Korn Shell... (3 Replies)
Discussion started by: madmat
3 Replies

7. Shell Programming and Scripting

Bourne shell & Korn shell

Could some one tell me the difference btw Bourne shell and the Kshell? Which is more flexible and reliable in terms of portability and efficiency. When i type the following command .. $ echo $SHELL yields me /bin/sh Does this tells me that I am in Bourne shell. If yes, how can i get... (6 Replies)
Discussion started by: bobby1015
6 Replies

8. Shell Programming and Scripting

korn shell for loops with expect issue

Hi I have the following Korn script having multiple for loops. #!/bin/ksh EXPECT=/usr/local/bin/expect exp_internal for d in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 i22 23 24 25 26; do for i in 01 02 03 04 05 06 07 ; do for h in 00 01 02 03 04 05 06 07 08 09 10 11 12... (2 Replies)
Discussion started by: cic
2 Replies

9. Shell Programming and Scripting

[Solved] Issue with using for loop as for in {2..6} in korn shell

Hi i have to cut columns 2 to 6 from a file and assign it to arrays , The following code works for ctcol in 2 3 4 5 6; do set -A a$ctcol $(cut -d, -f $ctcol test_file) done how ever this does not work for ctcol in {2..6}; do set -A a$ctcol $(cut -d, -f $ctcol test_file)... (4 Replies)
Discussion started by: 100bees
4 Replies

10. Shell Programming and Scripting

Calling sqlplus from Korn shell heredoc issue

Hi, I am facing an issue wherein some temporary files (here docs) are getting created in /tmp and are not getting deleted automatically. When i check the list of open files with below command i can see one file is getting appended continuously.(In this case /tmp/sfe7h.34p) The output is... (4 Replies)
Discussion started by: Navin_Ramdhami
4 Replies
Mail::SpamAssassin::Plugin::Shortcircuit(3pm)		User Contributed Perl Documentation	     Mail::SpamAssassin::Plugin::Shortcircuit(3pm)

NAME
Mail::SpamAssassin::Plugin::Shortcircuit - short-circuit evaluation for certain rules SYNOPSIS
loadplugin Mail::SpamAssassin::Plugin::Shortcircuit report Content analysis details: (_SCORE_ points, _REQD_ required, s/c _SCTYPE_) add_header all Status "_YESNO_, score=_SCORE_ required=_REQD_ tests=_TESTS_ shortcircuit=_SCTYPE_ autolearn=_AUTOLEARN_ version=_VERSION_" DESCRIPTION
This plugin implements simple, test-based shortcircuiting. Shortcircuiting a test will force all other pending rules to be skipped, if that test is hit. In addition, a symbolic rule, "SHORTCIRCUIT", will fire. Recomended usage is to use "priority" to set rules with strong S/O values (ie. 1.0) to be run first, and make instant spam or ham classification based on that. CONFIGURATION SETTINGS
The following configuration settings are used to control shortcircuiting: shortcircuit SYMBOLIC_TEST_NAME {ham|spam|on|off} Shortcircuiting a test will force all other pending rules to be skipped, if that test is hit. Recomended usage is to use "priority" to set rules with strong S/O values (ie. 1.0) to be run first, and make instant spam or ham classification based on that. To override a test that uses shortcircuiting, you can set the classification type to "off". on Shortcircuits the rest of the tests, but does not make a strict classification of spam or ham. Rather, it uses the default score for the rule being shortcircuited. This would allow you, for example, to define a rule such as body TEST /test/ describe TEST test rule that scores barely over spam threshold score TEST 5.5 priority TEST -100 shortcircuit TEST on The result of a message hitting the above rule would be a final score of 5.5, as opposed to 100 (default) if it were classified as spam. off Disables shortcircuiting on said rule. spam Shortcircuit the rule using a set of defaults; override the default score of this rule with the score from "shortcircuit_spam_score", set the "noautolearn" tflag, and set priority to "-100". In other words, equivalent to: shortcircuit TEST on priority TEST -100 score TEST 100 tflags TEST noautolearn ham Shortcircuit the rule using a set of defaults; override the default score of this rule with the score from "shortcircuit_ham_score", set the "noautolearn" and "nice" tflags, and set priority to "-100". In other words, equivalent to: shortcircuit TEST on priority TEST -100 score TEST -100 tflags TEST noautolearn nice shortcircuit_spam_score n.nn (default: 100) When shortcircuit is used on a rule, and the shortcircuit classification type is set to "spam", this value should be applied in place of the default score for that rule. shortcircuit_ham_score n.nn (default: -100) When shortcircuit is used on a rule, and the shortcircuit classification type is set to "ham", this value should be applied in place of the default score for that rule. TAGS
The following tags are added to the set available for use in reports, headers etc.: _SC_ shortcircuit status (classification and rule name) _SCRULE_ rulename that caused the shortcircuit _SCTYPE_ shortcircuit classification ("spam", "ham", "default", "none") SEE ALSO
"http://issues.apache.org/SpamAssassin/show_bug.cgi?id=3109" perl v5.14.2 2011-06-06 Mail::SpamAssassin::Plugin::Shortcircuit(3pm)
All times are GMT -4. The time now is 01:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy