I have 2 shell scripts - one calling another script. callouter.sh, callscript.sh.
callouter.sh :
export oraSchemaPass='scott/tiger'
echo 'This script is about to run another script'
sh ./callscript.sh
callscript.sh :
sqlplus -S ${oraSchemaPass} @/home/scripts/callscript.sql
callscript.sql is :
set pagesize 1000
select * from emp;
EXIT
This works perfectly fine. No error whatsoever. This is korn shell by the way.
Now I did 2 things :
encrypted the callouter.sh using openssl :
openssl enc -e -aes-256-cbc -salt -a -in /home/scripts/callouter.sh -out /home/scripts/callouter.enc -pass pass:W3lc0m3987
The file encrypted successfully.
Replaced the callouter.sh content with :
eval $( /home/scripts/decrypt.sh /home/scripts/callouter.enc )
Content of decrypt.sh is :
openssl enc -d -e -aes-256-cbc -a -in $1 -pass pass:W3lc0m3987
Now when I run callouter.sh I get the below error :
./callouter.sh: Line 1: export: `This script is about to run another script': not a valid identifier
./callouter.sh: Line 1: export: `./callscript.sh': not a valid identifier
Can anyone help me with how to resolve the error? I searched the error on net and it has got to do with invalid variables and improper uses of inverted quotes. I double checked my scripts and I got no such mistakes. I am starting to think the encrypted file is causing this.
Edit : purpose is to hide the password of Oracle schema. Yes for the purpose of the question I used the decrypt.sh. In the environment decrypt.sh will be accessed only by the user calling the scripts. And for that we have set up an environment variable SEC_DIR which will be the home directory of each user. So for example user 'A' will have SEC_DIR as /home/A/dev/sec_dir. Inside this decrypt.sh will be placed.
eval $( /home/scripts/decrypt.sh /home/scripts/callouter.enc )is like putting all your script's code into a single line. What's the purpose of this encryption? Hiding the hard-coded password incallouter.shby using a hard-coded password indecrypt.sh? Please edit your question to answer.callouter.shto the user who is allowed to acess the database in the same way as you plan to do for thedecrypt.shscript? Or add the login tocallscript.sqlscript and restrict the access tocallscript.sqlin a similar way?