Issue
s#!/bin/ksh
usrid=`sql_login.sh`
if [ "$?" -ne "0" ]; then
echo "sql login failed-Username/Password not available in control file"
exit -1
fi
a=`sqlplus -s ${usrid} <<EOF
set pause off
set heading off
set feedback off
set serveroutput off;
select 10 from dual;
exit;
EOF`
b=`sqlplus -s ${usrid} <<EOF
set pause off
set heading off
set feedback off
select 11 from dual;
exit;
EOF`
echo "Out of sqlplus session";
echo $a$b;
hi its giving output like 10 11? i need it 1011 how can i achive this?
solution:
a1=$(echo ${a#}) ;
b1=$(echo ${b#}) ;
c1=$a1$b1;
echo $c1;
Solution
There must be spaces included in the value of a (and probably b too)
You can get rid of the space by modify the value of the variable. assuming you have bash, ksh or other POSIX shell
echo ${a% }${b% }
will probably work. ${var% } says, for ${var} remove from the right of the variable's value a space char (if there is one there. If for some reason, you find that the space is in the front, like ' a', then use ${a# }, which means remove from the left of the variable's value a space char.
EDIT : kurumi's solution (assuming bash and POSIX shell is probably better) because then it doesn't matter where in the line that space value occurs.
BUT why don't you concatenate the two values and have just 1 sql query?
$ab=... select 10 + 11 from dual;
You may have to consult with you oracle friends to get this exactly right, but in the SQL Sybase DB (and probably MS SQL), this wouldn't be a problem.
ALSO, Stop using backquotes, they are deprecated since 1992 (at least) ab=$( cmd ) is so much nicer ;-)
Edit: fixed the "sidedness" of ${x% }
(right) and ${x# }
(left). 2023-10-16
IHTH
Answered By - shellter Answer Checked By - Willingham (WPSolving Volunteer)