Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking return code results in directory listing? 1

Status
Not open for further replies.

Elsebet

Programmer
Aug 7, 2003
38
0
0
US

Hi all -

I am getting rather odd behavior with this tiny piece of code. I'm basically trying to check the result of a sqlplus session with a korn shell script. It does work, however the echo $ret_code not only echos the error message I want but also a listing of the entire current directory as well. While this isn't a huge problem since I'm going to grep the error message out anyway, I'm curious as to why this is happening. If anyone has any input I'd appreciate it. Here is my code:

Code:
## Just a test script
log=/mkdm/src/scripts/trash/table_test.log
ret_code=$(sqlplus -s <<EOF
user/passwd
set heading off
set feedback off
@/mkdm/src/scripts/trash/table_test.sql;
EOF)
echo $ret_code
#if/else to check value of $ret_code here
exit 0
 
try
Code:
EOF
)

( instead of 'EOF)' )

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Have you tried commenting out the "echo $ret_code", to be sure that's where the directory listing is coming from?

Is the posted code the entire script, except of course the user and password?


Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 

Hi Vlad:

Moving the ) didn't help, unfortunately. Thanks for the tip though.

Hi Rod:

I did comment out the echo, however the directory listing ceases to show up (along with the error message I want).

Basically none of the Unix scripts that load our DW have any automatic error checking, which is what I am trying to add. All of the code is there except for a tiny if/then I will need to add to write to the log and send e-mail notifications.

Here is what I am getting as the value for #ret_code (trimmed slightly as it is pretty huge):

Code:
CREATE TABLE test_temp AS 999999999999999999999999 abi_canzip_out_temp.sql abi_ctype_dim020204.sql abi_ctype_dim030404.sql abi_ctype_dim033004.sql abi_ctype_dim0902.sql abi_ctype_dim101402.sql abi_nixie_customer_dim_new_temp.sql abi_nixie_prospect_dim_clr_temp.sql abi_qtrly1_batch060104.sql abi_qtrly1_batch9182003.sq abi_qtrly2_batch9182003.sql abi_qtrly3_batch12003.sql abi_qtrly3_batch9182003.sql abi_qtrly4_batch9182003.sql abi_qtrly5_batch9182003.sql abi_qtrly_temp.sql table_test.sql temp_fas.sql test.sql test.txt tms_batch_020204.sql tms_batchtemp.sql tms_cat_extract_imp.sql tms_cat_extracttemp.sql tms_clr_extracttemp.sql tms_fas_extracttemp.sql tms_frc_extracttemp.sql tms_fs_extracttemp.sql tms_fs_extracttemp_nl.sql tms_nat_extracttemp.sql tms_rg_extract_imp.sql tms_rg_extracttemp.sql tms_tms_extracttemp.sql tms_uty_extracttemp.sql tms_zip_temp.sql uty_batch_temp.sql vanessa_102203temp.sql vanessa_hh_test.sql ERROR at line 1: ORA-00955: name is already used by an existing object
Successful

Notice how the error is at the end.

Here is the contents of table_test.sql:
Code:
CREATE TABLE test_temp AS
SELECT *
FROM rental_sale_fact 
WHERE rownum < 5
/*
DROP TABLE test_temp
*/
/

I didn't think this DDL code would be any issue since it's being executed by sqlplus, but I'm going to try making a table without any asterisks to see if that changes anything. Will update!

Again thanks for the responses so far, much appreciated.
 
double quote like so:

echo "$ret_code"

the variable contains an asterisk, which is expanding.



Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 

Rod:

That did it! Thank you so much!

Just for the record, changing the DDL had no effect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top