solaris 10 and == operator


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting solaris 10 and == operator
# 1  
Old 04-04-2011
solaris 10 and == operator

Hi ,

I have .sh script and it's running on solaris 10 ( ksh is shell) and part of the script is :


Code:
orahome=`awk -F: '$1 == "'$oraserver'" {print $2}' /var/opt/oracle/oratab`
if [ "$orahome" == "" ]; then
        ORACLE_HOME=/opt/oracle/oracle_home;export ORACLE_HOME
else
        ORACLE_HOME=$orahome;export ORACLE_HOME

fi

when it tries to execute through cron , I am getting this error:

test: unknown operator ==


the same script if I execute through shell , it's working fine.

any thoughts ???
# 2  
Old 04-04-2011
== is a BASH thing. Try =.
# 3  
Old 04-04-2011
Thanks for the help.

after changed to = ( from ==) , it's working through cron but it's failing through shell:

awk: syntax error near line 1
awk: bailing out near line 1


Thanks
# 4  
Old 04-04-2011
Did you change the == in awk too? You only needed to change it in if [ "$orahome" == "" ]; then

---------- Post updated at 03:12 PM ---------- Previous update was at 03:11 PM ----------

Though actually a better way to do that is if [ -z "$orahome" ] ; then
# 5  
Old 04-04-2011
Probably more that == isn't an sh thing.

cron is using sh as its shell.

Change the if one, not the awk one... that one was fine.

Did you add this to the top of your script?:
Code:
#!/usr/bin/ksh

otherwise you will most likely have further problems down the line.
# 6  
Old 04-04-2011
Thanks.

is there a generic solution to work for both ksh and bash?

Thanks
# 7  
Old 04-04-2011
bash has nothing to do with sh on Solaris.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Unterminated <> operator

Hello. I'm self teaching myself and coded a program but I keep getting a illegal division by 0 error. I know what it means but I don't know where I am messing up. Here is the code: #!/usr/bin/perl @lines = <>; my %earned; my %possible; for ($i = 1; $i <... (6 Replies)
Discussion started by: Eric7giants
6 Replies

2. Shell Programming and Scripting

Conflict with the operator in IF

I am using a script like this source=$1 if ; then echo "got it" else echo "lost it" fi But the script is giving th error like script.ksh: ==: unknown test operator Can i know , is the syntax iam using is correct or suggest me a good way. ... (3 Replies)
Discussion started by: nani1984
3 Replies

3. Shell Programming and Scripting

Solaris test operator -gt

Hello people, I created the below script on HP-UX #!/bin/sh SESSION_NO=`sqlplus -s ${DRBILOUKOS_USER} <<EOF SET HEAD OFF @/export/home/drbiloukos/scripts/sessions_count/no_of_sessions.sql EOF` SESSION_THRESHOLD=250 MAX_SESSIONS=`sqlplus -s ${DRBILOUKOS_USER} <<EOF SET HEAD OFF... (2 Replies)
Discussion started by: drbiloukos
2 Replies

4. UNIX for Dummies Questions & Answers

+= operator

im new to bash scripting and im just using online tutorials and trial and error. i wanted to write a script to read numbers from a file and find their sum: #!/bin/bash theSum=0 for line in $(cat numbers.txt) do let "theSum = theSum + $line" echo "$line" done echo "The sum is... (3 Replies)
Discussion started by: astrolux444
3 Replies

5. UNIX for Dummies Questions & Answers

su with << operator

All, THe below is my script , when i use this i am getting nothing . could any one help me to know what is the use of the << operator below su - $8 << supo echo "exportsph $2 $1 $3 $4" exportsph $2 $1 $3 $4 supo i also tried as individual command su - userid << supo , when i do... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

6. Shell Programming and Scripting

Difference operator

Dear All, Good day, Just i would like to know that is there anything called difference operator in awk? For example, if a file contains 5 columns (as shown below) with both negative and positive values: Col1 Col2 Col3 Col4 Col5 I need to calculate the difference between Col1 and... (3 Replies)
Discussion started by: Fredrick
3 Replies

7. Programming

new operator

Hi, Please clear the 2 questions, 2 Questions, 1) Why the new as a operator? Is there any special reason why it can't be a function like malloc? 2) How are we considering sizeof(),new are as a opearartors? I know + - * / -> , . etc.. are operators, which criteria satisfied by sizeof()... (4 Replies)
Discussion started by: Nagapandi
4 Replies

8. HP-UX

Or operator with if

hi, i was trying to club to test condition with if. if -o ; then it is giving me error message, i wanted to ask how can we check two condtions with one if. (1 Reply)
Discussion started by: babom
1 Replies

9. Programming

ternary operator

How do I interpret the following ternary operation? fn_max(var_type a,var_type b,var_type c) { var_type t; return(t=((t>a?:t;a)>b)?:t;b)>c?:t;c) } Thanks (1 Reply)
Discussion started by: naan
1 Replies

10. Shell Programming and Scripting

And operator

I am trying to check two variables and if both are blank I want to set a flag: the_f3_pid=`rsh $target ps -ef | grep "f3.eab" | awk '{print $2}'` the_f7_pid=`rsh $target ps -ef | grep "f7.eab" | awk '{print $2}'` if ; then y=1 fi I get an error: ./script_name: test: 0403-021 ]... (4 Replies)
Discussion started by: rcarnesiii
4 Replies
Login or Register to Ask a Question