Sponsored Content
Top Forums UNIX for Dummies Questions & Answers New to shell script and lost.... Post 302247830 by jim mcnamara on Thursday 16th of October 2008 12:02:59 PM
Old 10-16-2008
$? is the return status of a process or command
Code:
#/bin/ksh
some_command goes here
it=$?
# one way
if [[ $it -eq 31 || $it -eq 11 ]] ; then
# do something
fi
# or this way, preserving the result of the test for further use
test_result=$(( it == 11 | it == 31 ))   #  C boolean operators:  ==, !=, >, >=, etc.
# at this point test_result is either 0 (not true) or 1 (true)

 

9 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

Lost Data Lost Admin

First time so excuse my ignorance please. I may not be accurately describing the issue. I have inherited a small lab mostly SUN V120s. We lost power and are trying to recover. Nope no backups... The primary issue I have is 1 box is an Oracle Server. It has 2 36Gb harddrives. I am able to... (3 Replies)
Discussion started by: murphsr
3 Replies

2. UNIX for Advanced & Expert Users

All alias in .profile lost when "script" command is called

Hi, I was trying to call "script <an ip add>" command from .profile file to log everything whenever anyone logs in to this user. I did the following at the end of .profile. 1) Extracted the IP address who logged in 2) Called script < ip add> . The problem I am facing is all, aliases etc. written... (3 Replies)
Discussion started by: amicon007
3 Replies

3. Post Here to Contact Site Administrators and Moderators

My shell pipe 2 multipipes thread is lost ?

Hi, yesterday I have got reply in my thread how to redirect shell pipe to 2 pipes. I would read that answer once again, as my re.re. is also lost Jack (6 Replies)
Discussion started by: jack2
6 Replies

4. Homework & Coursework Questions

brand new user!.. Lost on BASH script writing

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I have just gotten into writing bash scripts for a class, part of the assignment is to read and be able to tell... (4 Replies)
Discussion started by: Byrang
4 Replies

5. Shell Programming and Scripting

Data pipe lost when using ssh in shell script

Hi, I want to do SSH on many different machines and then run some commands on them. A binary application randomly generates IP addresses and my script will take care of doing SSH. $ ./IPGen.exe | ./myScript.sh my script looks like this: while read line; do result1=$(ssh $line... (2 Replies)
Discussion started by: siavash
2 Replies

6. Homework & Coursework Questions

Lost in shell script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Hey whats up everyone, Currently I'm stuck. In this question I have to use the following commands test, shift,... (7 Replies)
Discussion started by: AdamSahp
7 Replies

7. Shell Programming and Scripting

Why commands inside bash script lost effectiveness?

Hi, I have a bash script to run many system commands on CentOS machine, but I am puzzled by some commands had no effect on parent environment. For example, I want to refresh the desktop xdg menu when some processes added or deleted items from desktop xdg menu. If I run "killall gnome-panel"... (4 Replies)
Discussion started by: hce
4 Replies

8. Programming

Learning python, lost with script

Hi there, im just having a hard time understanding why this code does not print anything that is suppose to print: score = raw_input ('what is your score? \n') try: if 1.0 == float(score) >= 0.9: print "A" elif 0.9 > float(score) >= 0.8: ... (1 Reply)
Discussion started by: la2015
1 Replies

9. Shell Programming and Scripting

The Shell lost the inverted comma in a nested ssh command

Hi, i want use this Comand for my psql request sh ssh -o StrictHostKeyChecking=no rootatemailaddress.de sudo psql -U postgres -c "select pg_terminate_backend(pid) from pg_stat_activity where datnam=\'$DB\';"'" but the shell lost the inverted comma for datnam=\'$DB\'. The request deliver... (2 Replies)
Discussion started by: peterpane007
2 Replies
boolean(3pm)						User Contributed Perl Documentation					      boolean(3pm)

NAME
boolean - Boolean support for Perl SYNOPSIS
use boolean; do &always if true; do &never if false; do &maybe if boolean($value)->isTrue; and: use boolean ':all'; $guess = int(rand(2)) % 2 ? true : false; do &something if isTrue($guess); do &something_else if isFalse($guess); and: use boolean -truth; die unless ref(42 == 42) eq 'boolean'; die unless ("foo" =~ /bar/) eq '0'; DESCRIPTION
Most programming languages have a native "Boolean" data type. Perl does not. Perl has a simple and well known Truth System. The following scalar values are false: $false1 = undef; $false2 = 0; $false3 = 0.0; $false4 = ''; $false5 = '0'; Every other scalar value is true. This module provides basic Boolean support, by defining two special objects: "true" and "false". RATIONALE
When sharing data between programming languages, it is important to support the same group of basic types. In Perlish programming languages, these types include: Hash, Array, String, Number, Null and Boolean. Perl lacks native Boolean support. Data interchange modules like YAML and JSON can now "use boolean" to encode/decode/roundtrip Boolean values. FUNCTIONS
This module defines the following functions: true This function returns a scalar value which will evaluate to true. The value is a singleton object, meaning there is only one "true" value in a Perl process at any time. You can check to see whether the value is the "true" object with the isTrue function described below. false This function returns a scalar value which will evaluate to false. The value is a singleton object, meaning there is only one "false" value in a Perl process at any time. You can check to see whether the value is the "false" object with the isFalse function described below. boolean($scalar) Casts the scalar value to a boolean value. If $scalar is true, it returns "boolean::true", otherwise it returns "boolean::false". isTrue($scalar) Returns "boolean::true" if the scalar passed to it is the "boolean::true" object. Returns "boolean::false" otherwise. isFalse($scalar) Returns "boolean::true" if the scalar passed to it is the "boolean::false" object. Returns "boolean::false" otherwise. isBoolean($scalar) Returns "boolean::true" if the scalar passed to it is the "boolean::true" or "boolean::false" object. Returns "boolean::false" otherwise. METHODS
Since true and false return objects, you can call methods on them. $boolean->isTrue Same as isTrue($boolean). $boolean->isFalse Same as isFalse($boolean). USE OPTIONS
By default this module exports the "true", "false" and "boolean" functions. The module also defines these export tags: :all Exports "true", "false", "boolean", "isTrue", "isFalse", "isBoolean" -truth You can specify the "-truth" option to override truth operators to return "boolean" values. use boolean -truth; print ref("hello" eq "world"), " "; Prints: boolean "-truth" can be used with the other import options. AUTHOR
Ingy doet Net <ingy@cpan.org> COPYRIGHT
Copyright (c) 2007, 2008, 2010, 2011. Ingy doet Net. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.12.4 2011-09-12 boolean(3pm)
All times are GMT -4. The time now is 06:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy