02-23-2008
What's wrong with this line: if ${TEST:?} ; then echo empty; fi
I want to print "empty" if $TEST is empty.
TEST=
if ${TEST:?} ; then echo empty; fi
But it doesn't work. What's wrong?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
How to write this condition in ksh?
if myfile is empty or myfile does not exist
then
do action1
fi
is this OK?
if ] -o ] then
then
do action1
fi
Thanks. (3 Replies)
Discussion started by: GNMIKE
3 Replies
2. Shell Programming and Scripting
hi,
I test number on a file, but I have a problem when my file is empty, because the test isn't realized , do you have a idea to realize treatment when file is empty
my test script shell
VALUE=5000
for i in `cat /tmp/list | awk ' FS="|" { print $2 } '`
do
if
then
... (13 Replies)
Discussion started by: francis_tom
13 Replies
3. UNIX for Dummies Questions & Answers
OS - AIX 6.1
I am have below entry in my .profile
DS_LIB=/opt/IBM/InformationServer/Server/DSEngine/bin
export DS_BIN
When I do echo $DS_BIN, echo is returning empty
$ echo $DS_BIN
$
I never had this kind of issue earlier, please help me.
Thanks
srimitta (4 Replies)
Discussion started by: srimitta
4 Replies
4. Shell Programming and Scripting
Hi
Trying to do like this :
echo "$variable1\n $(cat file.txt)"
but it only adds one time. When I run this cmd again with different variable it only replaces line of variable1.
How to add constantly line into first line in file ? (3 Replies)
Discussion started by: presul
3 Replies
5. Shell Programming and Scripting
FIle A
"A" 2 aa 34
3 ac
5 cd
"B" 3 hu 67
4 fg
5 gy
output shud be
A"" 2 aa 34
"A" 3 ac 34
"A" 5 cd 34
"B" 3 hu 67
"B" 4 fg 67
"B" 5 gy 67 (6 Replies)
Discussion started by: cdfd123
6 Replies
6. Shell Programming and Scripting
If a file is empty then it must print the message "no data found"
eg:
if then
echo "no data found"
your help is really appreciated. (3 Replies)
Discussion started by: javeedkaleem
3 Replies
7. Shell Programming and Scripting
Hi How Are you?
I am doing fine!
I need to go now?
I will see you tomorrow!
Basically I need to replace the entire line containing "doing" with a blank line:
I need to the following output:
Hi How Are you?
I need to go now?
I will see you tomorrow!
Thanks in advance.... (1 Reply)
Discussion started by: sags007_99
1 Replies
8. UNIX for Dummies Questions & Answers
Hello all!
I am on Mac (10.8.4) and my shell tcsh (man says version: Astron 6.17.00). Just to precise my tcsh:
echo $LC_CTYPE
UTF-8
I want to replace all ':' with a new line, to get all paths on one line. I don't find a way to make my shell accept the "\n"
My start was:
echo... (17 Replies)
Discussion started by: marek
17 Replies
9. Shell Programming and Scripting
Hello,
I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be:
SRVXPAPI001 ERRO JUN24 07:28:34 1775
REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F
... (8 Replies)
Discussion started by: Ferocci
8 Replies
10. Shell Programming and Scripting
Hello everyone,
I have written simple script below to check if ip is added to interface
#!/usr/local/bin/bash
IFCONFIG="/sbin/ifconfig"
SERVICE="/usr/sbin/service"
IP="79.137.X.X"
GREP=$(${IFCONFIG} | grep ${IP})
ip_quantity_check () {
echo ${GREP} | wc -l
}
if ];... (2 Replies)
Discussion started by: bryn1u
2 Replies
LEARN ABOUT PHP
db2_lob_read
DB2_LOB_READ(3) 1 DB2_LOB_READ(3)
db2_lob_read - Gets a user defined size of LOB files with each invocation
SYNOPSIS
string db2_lob_read (resource $stmt, int $colnum, int $length)
DESCRIPTION
Use db2_lob_read(3) to iterate through a specified column of a result set and retrieve a user defined size of LOB data.
PARAMETERS
o $stmt
- A valid stmt resource containing LOB data.
o $colnum
- A valid column number in the result set of the stmt resource.
o $length
- The size of the LOB data to be retrieved from the stmt resource.
RETURN VALUES
Returns the amount of data the user specifies. Returns FALSE if the data cannot be retrieved.
EXAMPLES
Example #1
Iterating through different types of data
<?php
/* Database Connection Parameters */
$db = 'SAMPLE';
$username = 'db2inst1';
$password = 'ibmdb2';
/* Obtain Connection Resource */
$conn = db2_connect($db,$username,$password);
if ($conn) {
$drop = 'DROP TABLE clob_stream';
$result = @db2_exec( $conn, $drop );
$create = 'CREATE TABLE clob_stream (id INTEGER, my_clob CLOB)';
$result = db2_exec( $conn, $create );
$variable = "";
$stmt = db2_prepare($conn, "INSERT INTO clob_stream (id,my_clob) VALUES (1, ?)");
$variable = "THIS IS A CLOB TEST. THIS IS A CLOB TEST.";
db2_bind_param($stmt, 1, "variable", DB2_PARAM_IN);
db2_execute($stmt);
$sql = "SELECT id,my_clob FROM clob_stream";
$result = db2_prepare($conn, $sql);
db2_execute($result);
db2_fetch_row($result);
$i = 0;
/* Read LOB data */
while ($data = db2_lob_read($result, 2, 6)) {
echo "Loop $i: $data
";
$i = $i + 1;
}
$drop = 'DROP TABLE blob_stream';
$result = @db2_exec( $conn, $drop );
$create = 'CREATE TABLE blob_stream (id INTEGER, my_blob CLOB)';
$result = db2_exec( $conn, $create );
$variable = "";
$stmt = db2_prepare($conn, "INSERT INTO blob_stream (id,my_blob) VALUES (1, ?)");
$variable = "THIS IS A BLOB TEST. THIS IS A BLOB TEST.";
db2_bind_param($stmt, 1, "variable", DB2_PARAM_IN);
db2_execute($stmt);
$sql = "SELECT id,my_blob FROM blob_stream";
$result = db2_prepare($conn, $sql);
db2_execute($result);
db2_fetch_row($result);
$i = 0;
/* Read LOB data */
while ($data = db2_lob_read($result, 2, 6)) {
echo "Loop $i: $data
";
$i = $i + 1;
}
} else {
echo 'no connection: ' . db2_conn_errormsg();
}
?>
The above example will output:
Loop 0: THIS I
Loop 1: S A CL
Loop 2: OB TES
Loop 3: T. THI
Loop 4: S IS A
Loop 5: CLOB
Loop 6: TEST.
Loop 0: THIS I
Loop 1: S A BL
Loop 2: OB TES
Loop 3: T. THI
Loop 4: S IS A
Loop 5: BLOB
Loop 6: TEST.
SEE ALSO
db2_bind_param(3), db2_exec(3), db2_execute(3), db2_fetch_row(3), db2_prepare(3), db2_result(3).
PHP Documentation Group DB2_LOB_READ(3)