下面是一个用于获取 2 个输入参数值的 shell 脚本,
asd#@#g#@#h#@#j@#@k
候选人ID
这给了我们输出
string0 asd
string1 g
string2 h
.
.
.
candidateid
.
.
.
(& 然后在 Oracle 查询中使用这两个参数)
现在的问题是,当我尝试用空格传递第一个参数时,上面的代码失败了。
例如:/TOM/Process Folders/System Drive/a.jpg
上述给定位置应被视为第一个字符串。如果我在双引号内给出上述内容,那么它可以正常工作。但是我得到的上述参数没有引号。
#!/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