Help with reading parameter.

Hi,.
I need a help with below strange behaviour.
I use into script parameters as
read A
read B
and my parameter B (password from Active directory) is changed by adding backslash to all characters (123456as; -> \1\2\3\4\5\6\a\s\:wink: and I use it as parameter into script.
When I pass it to Oracle utility FNDCPASS it enclosed into quotation strings and therefore I recieved all with \'s.
Is exist posibility pass parameter without ".
P.S.
Piece of code is ->

read A
read -r B

username=`echo $A`
echo "We have username $username ...."
pass=`echo $B`
echo "We have old password $pass ...."
passnew=`echo $pass | sed 's/./\\\&/g'`
echo "We have new password ------"$passnew"----- ...."
......


FNDCPASS apps/${password} 0 Y system/${system} USER ${username}  ${passnew}

Thanks and wait for answers. Staas.

please share some code chunks .. or explain the issue,
what are you want to do ??

Hi.
This is code of my script->

#!/bin/ksh

. ~/applprd.env


read A
read B

username=`echo $A`
echo "We have username $username ...."
pass=`echo $B`
echo "We have old password $pass ...."
passnew=`echo $pass | sed 's/./\\\&/g'`
echo "We have new password ------"$passnew"----- ...."

# Recieve apps and system password ...... 
password=`grep -i password $TOOLS_CONFIG_HOME/../iAS/Apache/Apache/../modplsql/cfg/wdbsvr.app | grep -v portal | cut -d"=" -f2 | sed
 's/ //g'| head -1`
digits_to_cut=`echo ${password} | sed 's/[a-zA-Z]//g' | awk '{print length($1)}'`
if [ ${digits_to_cut} -eq 4 ]; then
  begin_system=`echo ${password} |  sed "s/.\{${digits_to_cut}\}$//" | sed 's/.$/s/g'`
  digits=`echo ${password} | sed 's/[A-Za-z]//g'`
  system=${begin_system}${digits}
else
  begin_system=`echo ${password} |  sed "s/.\{5\}$//" | sed 's/.$/s/g'`
  digits=`echo ${password} | awk '{ print substr($1,length($1)-4,length($1)) }'`
  system=${begin_system}${digits}
fi



# We  recieve user id for changing password ....
USERID=`sqlplus -s apps/$password@ORAPRD_BALANCE << END
set pagesize 0 feedback off verify off heading off echo off
SELECT to_char(a.user_id)
FROM fnd_user a, per_all_people_f f
where a.EMPLOYEE_ID = f.person_id
AND sysdate between f.effective_start_date AND f.effective_end_date
and a.end_date is null
and a.user_name=upper('${username}');
exit;
END`


if [ "${USERID:-"CONTRACT_ID"}" = "CONTRACT_ID" ] ; then
USERID=`sqlplus -s apps/$password@ORAPRD_BALANCE << END
set pagesize 0 feedback off verify off heading off echo off
select to_char(a.user_id)
from fnd_user a
where a.user_name = '${username}';
exit;
END`
fi

echo "We have user_name = ${username} and it's user_id = ${USERID} ....."

# Changing password for specific user ....
cd $FND_TOP/bin
FNDCPASS apps/${password} 0 Y system/${system} USER ${username}  ${passnew}
#echo "User ${username} changed password on `date`  with password ${pass} ....." >> /opt/idm.log 

I run this script in EOF manner ->

./idm.sh << EOF
TEST_HR
123456as;
EOF

I can not use transfer parameter into script due to it cause problem with some spec. characters (like & ' '' ;). Therefore I transfer them with read command. (as I explained above).
After parameter B is read it go as passnew into FNDCPASS utility and all \'s before characters are entered into DB.
When you run FNDCPASS from command line with \'s all OK.
I found, that passnew enclose with " and this cause problem.
What you can advice with this issue.
Thanks Staas.

I did not get you correctly.

/home/ravi>v="123456as"
/home/ravi>echo "$v"  | sed 's/./\\\&/g'
\&\&\&\&\&\&\&\&

The above snippet from you code , does not work OK. Not sure what exactly you are trying to change here.

Can you pls post a sample input and expected output.

Hi.
Thanks for replay
This is strange also for me. I mean if you into command line you need run echo "$v" | sed 's/./\\\0/g'

but if you into script you need run echo "$v" | sed 's/./\\\&/g'

Thanks Staas.

Hello,

It's nothing to whether it's inside the script or outside.

 
i=`echo "1234Rgt" | sed 's/./\\\&/g'`

echo $i

 
\1\2\3\4\R\g

Which does mean inside the backquote (`) the single quotes " ' " are interpreted differently.

instead you use sed "s/./\\\&/g" which works same in/out side script