Can I suggest a case statement to simplify to logic.
Use break statement to leave while loop. Also notice some glob matching to allow upper or lower case first letter and quit/exit/done to leave.
Also quick note on posting code to this forum, if you put [code] and [/code] tags around the code it stops any formatting (like indenting) from being lost as you can see above.
Last edited by Chubler_XL; 08-29-2013 at 11:33 PM..
I am attempting to pass a string into awk and loop through it, and then for every occurrance of a certain character perform an action. In this case, for example, echo 1 for each time character r is found in the string. Except I can't get it to work. Could someone please tell me why?
echo... (7 Replies)
#!/usr/bin/ksh
echo Please enter
while read n
do
echo $n >> datafile
done
question:
How can I enject an if statement that if the users enter 0 (zero) the program will exit?
this is what I have but not working
#!/usr/bin/ksh
echo Please enter number
while read n
do
if $n=0
then... (2 Replies)
I'm having a question about for loops. (bash)
I have the following for example:
for file in `ls *.txt`
do
read file ...
done
Now when there is a file present there is no problem, now when there is no file present I get the following output in my standard mail box : "No such... (4 Replies)
Hello I am very new to shell and I bought some books and trying to learn it. I started trying to write a script that will take a number and count it down to 1 with commas in between. This number can only be one argument. If lower than one or higher than one argument it sends an error message. ... (4 Replies)
I am writing a bash script that asks the user for input and I need it to repeat until the user selects quit.. I dont know how to write the loop for it I searched all over but i still do not get it.. if anyone could help with this it would be greatly apprciated here is my script so far:
#!... (2 Replies)
Hey guys,
a=`cat abc | wc -l`
b=`cat def | wc -l`
if $a== $b
then
echo "a"
else
echo "b"
fi
I want the if condition to retry itself , untill a==b.
I can't use goto statemt.
Please help.
Thanx in advance.
Please use next time code tags for your code and data (5 Replies)
Hi,
I tried to go through a lot of online material but could not find concrete solution.
My issues is like this :
I've got a input file like this :
<a>
<startDate>19700101000000</startDate>
<endDate>20300101000000</endDate>
</a>
... (12 Replies)
I need to match multiple values in a single column in a file:
example:
Source file:
abd,123,one
def,232,two
ghi,987,six
Target file:
12345,abcde,123
09876,zxvyr,566
56789,lmnop,232
Variable:
var1=`grep 2 sourcefile | awk '{print$1}'
essentially, echo "$var1" would read:... (2 Replies)
I have the basic command written in bash
for element in 1 2
do
if ]; then
set el = "t"
else
set el = "p"
fi
done
but i get the following error
syntax error near unexpected token `for'
` for element in 1 2'
What should i do differently? (3 Replies)
I have to create a couple of files within a directory structure.
Filename stays the same, but at the end of each file, the number appears.
Example:
File needs to be created within directory c:\temp
File Name will stay the same (testfile), but extension will increase, starting at 01 - example... (1 Reply)
Discussion started by: HenkTrumpie
1 Replies
LEARN ABOUT PHP
db2_stmt_error
DB2_STMT_ERROR(3) 1 DB2_STMT_ERROR(3)db2_stmt_error - Returns a string containing the SQLSTATE returned by an SQL statementSYNOPSIS
string db2_stmt_error ([resource $stmt])
DESCRIPTION
Returns a string containing the SQLSTATE value returned by an SQL statement.
If you do not pass a statement resource as an argument to db2_stmt_error(3), the driver returns the SQLSTATE value associated with the
last attempt to return a statement resource, for example, from db2_prepare(3) or db2_exec(3).
To learn what the SQLSTATE value means, you can issue the following command at a DB2 Command Line Processor prompt: db2 '? $sqlstate-
value'. You can also call db2_stmt_errormsg(3) to retrieve an explicit error message and the associated SQLCODE value.
PARAMETERS
o $stmt
- A valid statement resource.
RETURN VALUES
Returns a string containing an SQLSTATE value.
SEE ALSO db2_conn_error(3), db2_conn_errormsg(3), db2_stmt_errormsg(3).
PHP Documentation Group DB2_STMT_ERROR(3)