11-29-2010
linux-hhaq:/apps/informatica/current/pmserver/tes/scripts # if [[ `echo` ]]; then echo yes; else echo no; fi
no
echo returns nothing
linux-hhaq:/apps/informatica/current/pmserver/tes/scripts # if [[ `echo aa` ]]; then echo yes; else echo no; fi
yes
echo returns 'aa'
linux-hhaq:/apps/informatica/current/pmserver/tes/scripts # if [[ `function_not_defined` ]]; then echo yes; else echo no; fi
yes
It returns an error on standard output (i redirected 2>/dev/null and got an output !?)
linux-hhaq:/apps/informatica/current/pmserver/tes/scripts # function_return1()
> {
> return 1
> }
linux-hhaq:/apps/informatica/current/pmserver/tes/scripts # if [[ `function_return1` ]]; then echo yes; else echo no; fi
no
It echoes NOTHING or don't use backticks !
linux-hhaq:/apps/informatica/current/pmserver/tes/scripts # function_return0() { return 0; }
linux-hhaq:/apps/informatica/current/pmserver/tes/scripts # if [[ `function_return0` ]]; then echo yes; else echo no; fi
no
It echoes NOTHING or don't use backticks !
---------- Post updated at 16:01 ---------- Previous update was at 15:56 ----------
When You use backticks (it's better to use $() which can be nested and is more readable), you evaluate the ouput of the function (what it echoes on stdout) but not the return code.
6 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm writing this script in Korn Shell, on AIX. The script will print a log file, and it needs to decide what region it's in before printing.
( the output of db2 "get instance" is either
"The current database manager instance is: db2q" or
"The current database manager instance is: db2u")
... (6 Replies)
Discussion started by: jpprial
6 Replies
2. UNIX for Dummies Questions & Answers
Hi folks
First, let me apologize in advance for the long message. I know this will sound like a typical "newbie" message but I am really working to understand the technology in order to make informed decisions.
I am currently in the process of evaluating Unix hardware and OS platforms for an... (5 Replies)
Discussion started by: Scooter
5 Replies
3. Shell Programming and Scripting
I'm tryning to do something like this,
I have this file:
spaces12tabgoodbye
spaces3tabhello
I want to copy to another file the lines that have the number above 10...
I thought using sort -rn but I don't know how to discard the lines that have the number below 10.
Any idea?
Thanks (3 Replies)
Discussion started by: pmpx
3 Replies
4. Shell Programming and Scripting
Hi all
I need help for the issue below.
I need to create script:
FORM_cmd=query || import
FORM_command=add
FORM_msisdn=389881234567
FORM_provcode=SK
FORM_attr=12
FORM_cmd can be "query" or "import"
when FORM_cmd="query" then execute -> spdci -cmd $FORM_cmd FORM_cmd
when... (3 Replies)
Discussion started by: vasil
3 Replies
5. Shell Programming and Scripting
Hello All,
Greetings !!
I have a query here to all is as follows:
Question: Let's say we are running a script in a UNIX box and we have opened an another session and then made changes in script of some statements NOT to be print some values(just an example) so when I am monitoring the... (5 Replies)
Discussion started by: RavinderSingh13
5 Replies
6. UNIX for Beginners Questions & Answers
-------
Output Screen
--------
Choose the option
-----------------
1.Input
2.Output
3.CFT Uniq
x.Exit
-----------------
2
Enter the Output flow IDF
PBL5572U
Enter the Output existing flow IDF
PBL5198H
sf_PBL5572U.cmd file exist in invalid path or doesn't exist (0 Replies)
Discussion started by: Vijaykannan T
0 Replies
LEARN ABOUT PHP
mssql_field_seek
MSSQL_FIELD_SEEK(3) MSSQL_FIELD_SEEK(3)
mssql_field_seek - Seeks to the specified field offset
SYNOPSIS
bool mssql_field_seek (resource $result, int $field_offset)
DESCRIPTION
Seeks to the specified field offset. If the next call to mssql_fetch_field(3) won't include a field offset, this field would be returned.
PARAMETERS
o $result
- The result resource that is being evaluated. This result comes from a call to mssql_query(3).
o $field_offset
- The field offset, starts at 0.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
EXAMPLES
Example #1
Using mssql_field_seek(3) on the example for mssql_fetch_field(3)
<?php
// Connect to MSSQL and select the database
mssql_connect('MANGOSQLEXPRESS', 'sa', 'phpfi');
mssql_select_db('php');
// Send a select query to MSSQL
$query = mssql_query('SELECT * FROM [php].[dbo].[persons]');
// Construct table
echo '<h3>Table structure for 'persons'</h3>';
echo '<table border="1">';
// Table header
echo '<thead>';
echo '<tr>';
echo '<td>Field name</td>';
echo '<td>Data type</td>';
echo '<td>Max length</td>';
echo '</tr>';
echo '</thead>';
// Dump all fields
echo '<tbody>';
for ($i = 0; $i < mssql_num_fields($query); ++$i) {
// Fetch the field information, notice the
// field_offset parameter is not set. See
// the mssql_field_seek call below
$field = mssql_fetch_field($query);
// Print the row
echo '<tr>';
echo '<td>' . $field->name . '</td>';
echo '<td>' . strtoupper($field->type) . '</td>';
echo '<td>' . $field->max_length . '</td>';
echo '</tr>';
// Move the internal seek pointer to the next
// row in the result set
mssql_field_seek($query, $i + 1);
}
echo '</tbody>';
echo '</table>';
// Free the query result
mssql_free_result($query);
?>
SEE ALSO
mssql_fetch_field(3).
PHP Documentation Group MSSQL_FIELD_SEEK(3)