comparison of strings in unix shell scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting comparison of strings in unix shell scripting
# 1  
Old 01-11-2008
comparison of strings in unix shell scripting

Hi

Code:
STORAGE_TYPE=$1

echo "########### SQL SESSION STARTED ###########"


VALUE=`sqlplus -S /nolog << THEEND

connect tcupro/tcupro_dev@bdd1optn 
SET SERVEROUTPUT ON
DECLARE
        V_STORAGE_TYPE   varchar2(3);
         V_ERR_MSG  varchar2(255) ;
	 V_LOG_LEVEL varchar2(200);
BEGIN

  V_STORAGE_TYPE :=  '$STORAGE_TYPE';
  V_ERR_MSG := 'SUCCESS';
  V_LOG_LEVEL := 'DETAIL';
dbms_output.put_line(V_STORAGE_TYPE);
  TCUPRO.TCU_PURGE_TABLES_DUP(V_STORAGE_TYPE, V_ERR_MSG,V_LOG_LEVEL);
dbms_output.put_line(V_ERR_MSG);

END;
/
EXIT;
THEEND`


echo $VALUE >./logs/TCU-`date '+%Y%m%d-%H%M%S'`-PURGE.log

Actuall this $value will have ' Success,Pl/sql procedure completed successfully.'
So I want to check that variable $value has success word or not.
and on the basis of that want to return exit code.
# 2  
Old 01-11-2008
Code:
echo $VALUE >./logs/TCU-`date '+%Y%m%d-%H%M%S'`-PURGE.log
echo "$VALUE" | grep -q 'SUCCESS' 
return $?

will return 1 on failure 0 on success - is that what you mean?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create a name of a file by comparison of strings

Hello everybody, I need to create a file name from string. The thing is: I have a directory with files e.g: test.123 test.234 test.345 test.987 The name should be made from the first and last name of file alphabetically and from the directory, they are in, eg. ... (2 Replies)
Discussion started by: satin1321
2 Replies

2. Shell Programming and Scripting

Comparison treating strings as zero integers

I'm trying to write a bash script to perform basic arithmetic operations but I want to run a comparison on the arguments first to check that they're a number greater than zero. I want an error to pop up if the arguments args aren't >= 0 so I have: if ! ]; then echo "bad number: $1" fi ... (14 Replies)
Discussion started by: TierAngst
14 Replies

3. UNIX for Dummies Questions & Answers

Unix Shell Scripting( Calling from Unix to PLSQL)

Hello Experts, I have the following questions to be discussed here at this esteemed discussion forum. I have two Excel sheets which contain Unix Commands llike creating directory the structure/ftp/Copy/Zip etc to basically create an environment. I need help in understanding some of... (1 Reply)
Discussion started by: faizsaadq
1 Replies

4. UNIX for Advanced & Expert Users

Comparison in Korn shell scripting

I have a scenario to implement in Korn shell script. Here it is.. I need to compare two values to see whether they are same or not. The issue is that the values coming in for comparison can be a string or an integer which can be determined during run time only. Which korn shell comparison... (2 Replies)
Discussion started by: vani123
2 Replies

5. Shell Programming and Scripting

How to extract exact strings in shell scripting

/Path/snowbird9/nrfCompMgrRave1230100920.log.gz:09/20/2010 06:14:51 ERROR Error Message. /Path/snowbird6/nrfCompMgrRave1220100920.log.gz:09/20/2010 06:14:51 ERROR Error Message. /Path/snowbird14/nrfCompMgrRave920100920.log.gz:09/20/2010 06:14:51 ERROR Error Message.... (0 Replies)
Discussion started by: Shirisha
0 Replies

6. Shell Programming and Scripting

Case insensitive comparison of strings

Hi All, In one shell script I have In variable "i" I am getting a full path of a file. Now I want to compare something like -- upper(*Nav*)) I dont want to do like below because in each CASE statement I doing so many operations. Please guide me. Thanks in advance... (4 Replies)
Discussion started by: vishalaksha
4 Replies

7. Shell Programming and Scripting

Comparison of two files which contains strings using Shell scripting or PERL

Hi, I need sample code to compare the two files line by line which contains text strings and to print the difference in the third file. Thanks in advance (1 Reply)
Discussion started by: sudhakaryadav
1 Replies

8. Shell Programming and Scripting

Matching strings in unix shell programming

#!bin/sh `clear` for i in $(seq -w 15 37); do #echo $i wget --dns-timeout=0.0005 http://napdweb${i}.eao.abn-iad.ea.com:8000/webcore/test/test.jsp -o 1 A=`cat 1` C=$(expr "$A" :... (7 Replies)
Discussion started by: veerumahanthi41
7 Replies

9. Shell Programming and Scripting

Comparison of 2 strings

I need some help with a script which accepts multiple rows of input (analysis from a virtual robot's testrun) from the standard in, and compares it as a whole with another file featuring erroneous data from a virtual robot's test run. What I want it to be able to do is slice off all the erroneous... (2 Replies)
Discussion started by: Retribution
2 Replies

10. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies
Login or Register to Ask a Question