07-05-2008
Without seeing the actual check_ok() it would be a little difficult to say exactly what your problem is. Unless you put in an explicit return statement, the routine will return the value of the last expression evaluated. If it always returns true then it would imply that the last expression in the subroutine either always returns true or has, coincidentally, always returned true in the cases you've tested.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello there!
Here is my problem. I hope I can get some help about it.
I need to know how can I get the return code of an application in the Unix shell script.
The script is like below:
PREVIOUS STATEMENT & VARIABLES
sqlplus scott/tiger @$sqldir/$sqlscript
NEXT STATEMENT (Like... (7 Replies)
Discussion started by: Shaz
7 Replies
2. Shell Programming and Scripting
Hello,
I still have problems when trying to figure out if the status of an ftp was successful. I ftp to different types (nt, vax, unix, etc...) of machines. I am trying to write a universal script that will ftp a file and then check to see if the ftp was successful. I have tried the... (12 Replies)
Discussion started by: blt123
12 Replies
3. Shell Programming and Scripting
hi, I set the crontab to execute script A every 5 minutes from 9:00 am to 4:00 pm everyday, now at 12:00am I want to run another script if and only if all the previous runs of script A return OK, can anyone tell me how it could be done? thank you very very much! (4 Replies)
Discussion started by: mpang_
4 Replies
4. Shell Programming and Scripting
Hi all
below is a snippet of my perl codesystem ("scp -pq $dest_file $path");How i can i trap the return status? ie if the scp fails how can i know ? (2 Replies)
Discussion started by: new2ss
2 Replies
5. HP-UX
I have the question:
How return the exit code from then assign :
VAR=$(command ) for ex. VAR=$(ls ....)
VAREXIT=$?
echo $VAREXIT
VAREXIT is equal to 0 if the directory exist or not exist. WHI??
if i execute the command direct from line-command , the value of $? is different if... (1 Reply)
Discussion started by: ZINGARO
1 Replies
6. Shell Programming and Scripting
I have two scripts. script1.sh looks
--------------------------------
#!/bin/bash
display()
{
echo "Welcome to Unix"
}
display
-----------------------------
Script2.sh
#!/bin/bash
sh script1.sh //simply calling script1.sh
------------------------------ (1 Reply)
Discussion started by: mvictorvijayan
1 Replies
7. UNIX for Dummies Questions & Answers
there is something wrong with my system. when I do this:
diff file1 file1 && echo 1
the output is 1.
but
diff file1 file2 >/dev/null && echo 1
output nothing
while
diff file1 file2 >/dev/null || echo 1
shows 1.
the same with "grep" return status. they are both GNU utilities.... (5 Replies)
Discussion started by: phil518
5 Replies
8. Shell Programming and Scripting
Hi can you explain me, what does variables $@ and $* return and how are they used, if can give me a sample example it could be helpful.
Thanks in advance,
Regards,
Abhishek S. (1 Reply)
Discussion started by: abhisheksunkari
1 Replies
9. Shell Programming and Scripting
Not sure where the problem is. I can run the script without any issue using the following command.
. /opt/app/scripts/cdc_migration.sh
But it fails with the below error when I try it this way
/opt/app/scripts/cdc_migration.sh
/opt/app/scripts/cdc_migration.sh: line 65: return: can only... (1 Reply)
Discussion started by: svajhala
1 Replies
10. Shell Programming and Scripting
Hi All,
Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition.
#Body
function1()
{
if
then
echo "exist"
else
echo "not exist"
}
#if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies
TEST(1) General Commands Manual TEST(1)
NAME
test - condition evaluation utility
SYNOPSIS
test expression
DESCRIPTION
The test utility evaluates the expression and, if it evaluates to true, returns a zero (true) exit status; otherwise it returns 1 (false).
If there is no expression, test also returns 1 (false).
All operators and flags are separate arguments to the test utility.
The following primaries are used to construct expression:
-b file
True if file exists and is a block special file.
-c file
True if file exists and is a character special file.
-d file
True if file exists and is a directory.
-e file
True if file exists (regardless of type).
-f file
True if file exists and is a regular file.
-g file
True if file exists and its set group ID flag is set.
-h file
True if file exists and is a symbolic link.
-n string
True if the length of string is nonzero.
-p file
True if file is a named pipe
-r file
True if file exists and is readable.
-s file
True if file exists and has a size greater than zero.
-t [file_descriptor]
True if the file whose file descriptor number is file_descriptor (default 1) is open and is associated with a terminal.
-u file
True if file exists and its set user ID flag is set.
-w file
True if file exists and is writable. True indicates only that the write flag is on. The file is not writable on a read-only file
system even if this test indicates true.
-x file
True if file exists and is executable. True indicates only that the execute flag is on. If file is a directory, true indicates
that file can be searched.
-z string
True if the length of string is zero.
string
True if string is not the null string.
s1 = s2
True if the strings s1 and s2 are identical.
s1 != s2
True if the strings s1 and s2 are not identical.
n1 -eq n2
True if the integers n1 and n2 are algebraically equal.
n1 -ne n2
True if the integers n1 and n2 are not algebraically equal.
n1 -gt n2
True if the integer n1 is algebraically greater than the integer n2 .
n1 -ge n2
True if the integer n1 is algebraically greater than or equal to the integer n2 .
n1 -lt n2
True if the integer n1 is algebraically less than the integer n2 .
n1 -le n2
True if the integer n1 is algebraically less than or equal to the integer n2 .
These primaries can be combined with the following operators:
! expression
True if expression is false.
expression1 -a expression2
True if both expression1 and expression2 are true.
expression1 -o expression2
True if either expression1 or expression2 are true.
(expression)
True if expression is true.
The
-a operator has higher precedence than the -o operator.
GRAMMAR AMBIGUITY
The test grammar is inherently ambiguous. In order to assure a degree of consistency, the cases described in the IEEE Std 1003.2
("POSIX"), section D11.2/4.62.4, standard are evaluated consistently according to the rules specified in the standards document. All other
cases are subject to the ambiguity in the command semantics.
RETURN VALUES
The test utility exits with one of the following values:
0 expression evaluated to true.
1 expression evaluated to false or expression was missing.
>1 An error occurred.
BUGS
Named pipes are not implemented in 2.11BSD.
STANDARDS
The test function is expected to be IEEE Std 1003.2 ("POSIX") compatible.
7th Edition March 13, 1995 TEST(1)