Below is a shell script for taking 2 input parameter values,
asd#@#g#@#h#@#j@#@kcandidateid
which gives us output as
string0 asd
string1 g
string2 h
.
.
.
candidateid
.
.
.
(& then both parameters are used in Oracle queries)
Now the problem is that the above code fails when I try to pass 1st parameter with spaces.
eg: /TOM/Process Folders/System Drive/a.jpg
The above given location should be considered as 1st string. If I give the above within Double Quotes, then it works fine. But the above parameter that I am getting is without quotes.
#!/bin/bash
input=$1
input1=$2
IFS='#' read -a arr <<< "${input//#@#/#}"
for((i=0;i<${#arr[@]};i++))
do
echo "String$i ${arr[i]}"
done
read passportphotos <<< "${arr[0]}"
read academiccertificates <<< "${arr[1]}"
read dateofbirth <<< "${arr[2]}"
read addressproof <<< "${arr[3]}"
read pancard <<< "${arr[4]}"
read pfnominationform <<< "${arr[5]}"
read gratuitynomination <<< "${arr[6]}"
read investmentdeclaration <<< "${arr[7]}"
read resignationletter <<< "${arr[8]}"
read acceptanceoffer <<< "${arr[9]}"
read acceptancecodeofconduct <<< "${arr[10]}"
read medicalnomination <<< "${arr[11]}"
read backgroungverification <<< "${arr[12]}"
read personaldataform <<< "${arr[13]}"
echo $passportphotos
echo $academiccertificates
echo $dateofbirth
echo $addressproof
echo $pancard
echo $pfnominationform
echo $gratuitynomination
echo $investmentdeclaration
echo $resignationletter
echo $acceptanceoffer
echo $acceptancecodeofconduct
echo $medicalnomination
echo $backgroungverification
echo $personaldataform
instant_client="/root/ora_client/instantclient_11_2"
view=`$instant_client/sqlplus -s HRUSER/HRUSER@TOMLWF <<EOF
set heading off
set feedback off
set lines 10000
set pagesize 10000
insert into EMPLOYEEDOCUMENTS VALUES ((SELECT EMPLOYEEID FROM EMPLOYEE WHERE CANDIDATEID='$input1'),'Resume','Doc','$passportphotos','Y','HR',(SELECT SYSDATE FROM DUAL),'HR',(SELECT SYSDATE FROM DUAL),'HR',(SELECT SYSDATE FROM DUAL));
`
echo $view
"But the above parameter that i am getting is without qoutes"? How are you invoking the script that you cannot add the quotes around it?between guava & #@#grapeas your string, you must be able to say, either that after each pair of whitespaces you'll have an argument, or that your arguments are separated by the&, which would give youarg1=between guavaandarg2= #@#grape