I've used vi editor to write this script, provided permission, but I invoke it
it is prompting end-of-file errors.. I'm not sure what is causing that error..
would like some help.. I've attached details..
perseus.gasleak(/tmp/v_tst)% ls -l f2.sh
-rwxr-xr-x 1 gasleak 393 Feb 15 14:12 f2.sh
perseus.gasleak(/tmp/v_tst)% cat f2.sh
#!/bin/sh
#. /u01/app/oracle/local/bin/cron_env_$ORACLE_SID
file_name='./services.dat'
if [ -f $file_name ]; then
echo "file found " $file_name
sqlplus /nolog <<EOF >./tst.log
connect test/test
set feedback off
set echo on
@./glspreltr.sql
exit
EOF
fi
mv $file_name $file_name_%m%d%Y
# echo $file_name
perseus.gasleak(/tmp/v_tst)%
perseus.gasleak(/tmp/v_tst)% ./f2.sh
./f2.sh: syntax error at line 16: `end of file' unexpected
perseus.gasleak(/tmp/v_tst)%
my intent for that line is to invoke sqlplus , write log activities to a specific file name and call a script, which is executing two PL/Sql stored procedures..
Yes. That is an issue. The here-document started with the line:
sqlplus /nolog <<EOF
does not end until there is a line that just contains the three characters EOF and a line terminating <newline> character. If you started the here document with <<-EOF instead of <<EOF , the here-document could be terminated by a line just containing zero or more leading <tab> characters, the three characters EOF , and a line terminating <newline> character. Any <space> characters before the here-document terminator string will cause that line to included in the here-document and keep it from being recognized as the terminator.
ok.. to test further, I've removed all of the spaces and used <<EOF>> tag as suggested. I'v also used db connection login/pw.. this time it didn't prompt end-of-file error.. but file rename didn't work..
if I could I've two follow-up questions -
#!/bin/sh
#. /u01/app/oracle/local/bin/cron_env_$ORACLE_SID
file_name='./services.dat'
if [ -f $file_name ]; then
echo "file found " $file_name
sqlplus /nolog <<-EOF >./tst.log
connect test/test
set feedback off
set echo on
@./glspreltr.sql
exit
EOF
fi
mv $file_name $file_name_%m%d%Y
echo $file_name
output:
perseus.gasleak(/tmp/v_tst)% ./f2.sh
file found ./services.dat
./services.dat
qes1: in the file rename some how did not like "%m%d%Y" format.. why?
qes2: is there way to determine when the file was written mm-dd-yy-hh-mm and use that for the rename. if so, please suggest how to do that.