Help with reading parameter.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with reading parameter.
# 1  
Old 06-27-2011
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\Smilie 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 ->
Code:
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.

Last edited by joeyg; 06-27-2011 at 11:45 AM.. Reason: Please wrap CodeTags around scripts and data
# 2  
Old 06-27-2011
please share some code chunks .. or explain the issue,
what are you want to do ??
# 3  
Old 06-27-2011
Hi.
This is code of my script->
Code:
#!/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 ->
Code:
./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 & ' '' Smilie. 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.

Last edited by Franklin52; 06-28-2011 at 03:39 AM.. Reason: Please use code tags for code and data samples, thank you
# 4  
Old 06-27-2011
I did not get you correctly.

Code:
/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.
# 5  
Old 06-28-2011
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.
# 6  
Old 06-28-2011
Hello,

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

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

echo $i
Code:
 
\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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To call Oracle procedure by reading parameter file in UNIX

hi Guys, is there a way to pass parameter into oracle store procedure by reading date range in file and increment accordingly. Something like this file.txt 01-JAN-2015 03-JAN-2015 sqlplus -s user/pwd@DB execute TEST( to_date( '01-JAN-2015, 'dd.mm.yyyy' ), to_date( '03-JAN-2015', ... (1 Reply)
Discussion started by: rohit_shinez
1 Replies

2. Shell Programming and Scripting

Call Script with Parameter (that has another parameter)

Hi. How do I achieve this sh /EDWH-DMT02/script/MISC/exec_sql.sh "@/EDWH-DMT02/script/others/CSM_CKC/Complete_List.sql ${file_name}" Complete_List.txt The /EDWH-DMT02/script/MISC/exec_sql.sh has two parameters and it's working fine with this sh /EDWH-DMT02/script/MISC/exec_sql.sh... (7 Replies)
Discussion started by: aimy
7 Replies

3. Shell Programming and Scripting

Resolving a parameter which is passed as parameter

Hi, I have the following files. ->cat scr.sh export TMP_DIR=/home/user/folder1 export TMP_DIR_2=/home/user/folder2 while read line do cat "$line" done<file_list.dat ------------------------ -> cat file_list.dat $TMP_DIR/file1.txt $TMP_DIR_2/file2.txt --------------------------- -> cat... (6 Replies)
Discussion started by: barath
6 Replies

4. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

5. Shell Programming and Scripting

Command that takes one parameter and then searches for the passed in parameter

Hi I am looking for a unix command or a small shell script which can takes one parameter and then searches for the passed in the parameter in any or all files under say /home/dev/ Can anyone please help me on this? (3 Replies)
Discussion started by: pankaj80
3 Replies

6. Shell Programming and Scripting

Reading a variable from parameter file

HI all, I have a parameter file with entries like $$Name =Abhinav $$CUTOFF_DATE = 11/11/2209 I am reading a variable from this file using a awk command like : var2=`awk -F"" "/CUTOFF_DATE/{f=$1;}{print f;}" InputFIleName` but facing an error like awk: cmd. line:1:... (3 Replies)
Discussion started by: abhinav192
3 Replies

7. UNIX for Dummies Questions & Answers

Reading from a file(passing the file as input parameter)

hi I have a shell script say primary.sh . There is a file called params my scenario is primary.sh should read all the values and echo it for example i should pass like $primary.sh params output would be Abc ... (2 Replies)
Discussion started by: ssuresh1999
2 Replies

8. Shell Programming and Scripting

Reading a Parameter File

Hi, I need to read the parameters from a file and assign them to Global variables. I need to read a specific parameter value every time and pass it to the other script. Suppose i have a parameter file like PARAM.txt PAR1= VAL1 PAR2= VAL2 PAR3= VAL3 I want to read PAR2 file and in the... (1 Reply)
Discussion started by: Raamc
1 Replies

9. Shell Programming and Scripting

reading the parameter from another file

I have a script where 3 parametrs are passed to it and it creates the file for each site form a template. If i want to get the 3rd parameter (which is the site) passed to the script to come from another file how I can change the script tp acheive it? Here is my script: what i have in the... (15 Replies)
Discussion started by: dsravan
15 Replies

10. Shell Programming and Scripting

how do I make dynamic parameter names? Or get the value of a parameter evaluated twi

Say I write something like the following: var1=1 var2=2 for int in 1 2 do echo "\$var$int" done I want the output to be: 1 2 Instead I get something like: $var1 $var2 (2 Replies)
Discussion started by: Awanka
2 Replies
Login or Register to Ask a Question