LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   If the file does not exists, do the control file (https://www.linuxquestions.org/questions/linux-newbie-8/if-the-file-does-not-exists-do-the-control-file-887381/)

newtoshl 06-20-2011 01:42 PM

If the file does not exists, do the control file
 
This piece of code is working somewhat.
I need to search for a file in a directory
It is define, if the file is there execute the control file, if it is not there don't execute the ctl file (sqlldr), it is executing the sqqlldr all the time, I added the if statement(commented out)
##if [ -f "$pfile_fq" ]
but it is not working

{code}
##if [ -f "$pfile_fq" ]
##then
export PATH=/usr/local/bin:$PATH
export ORACLE_SID=$1
export ORAENV_ASK=NO
. oraenv
export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME:$ORACLE_BASE
#echo $PATH
#echo $ORACLE_SID
echo "Running command: /u01/app/oracle/product/11.2.0/bin/sqlldr xxx/xxx@${1} control=/u01/app/banner/test/sub/plus/ssearc
h_ctl.sql log=$pbase/$log_file"
/u01/app/oracle/product/11.2.0/bin/sqlldr xxx/xxxx@${1} control=/u01/app/banner/test/sub/plus/ssearch_ctl.sql log=$pbase/$l
og_file
##mv $pfile_fq $pfile_mv
##else
# #printf "\nthe file does not exist: \n"
## echo "The file does not exist: $pfile_fq"
##fi
{code}

Tinkster 06-20-2011 02:00 PM

Hi, welcome to LQ!

You almost got the code tags right ;} try [ code ] and [ /code ]
(w/o the spaces between brackets and "code").


Try this:
Code:

if [ -f "$pfile_fq" ] ; then
  export PATH=/usr/local/bin:$PATH
  export ORACLE_SID=$1
  export ORAENV_ASK=NO
  . oraenv
  export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME:$ORACLE_BASE
  echo $PATH
  echo $ORACLE_SID
  echo "Running command: /u01/app/oracle/product/11.2.0/bin/sqlldr xxx/xxx@${1} control=/u01/app/banner/test/sub/plus/ssearch_ctl.sql log=$pbase/$log_file"
  /u01/app/oracle/product/11.2.0/bin/sqlldr xxx/xxxx@${1} control=/u01/app/banner/test/sub/plus/ssearch_ctl.sql log=$pbase/$log_file
  mv $pfile_fq $pfile_mv
else
 printf "\nthe file does not exist: \n"
 echo "The file does not exist: $pfile_fq"
fi



Cheers,
Tink


All times are GMT -5. The time now is 11:18 PM.