Cannot open [No such file or directory]


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cannot open [No such file or directory]
# 8  
Old 06-28-2012
@duke0001
My feeling is don't delete the log file, just null it.
Code:
if [ -f $LOGFILE ]; then
  > $LOGFILE
fi

The error message is flagged as line 41. There are not 41 lines in the script posted.
Is this the complete script?
Is this the right script?
Is there some displaced spurious code way down beyond what you think is the last line of the script I wonder????
# 9  
Old 06-28-2012
thanks. I followed your command to rename script as move_audit.sh

Then run it and got the same error message.

Code:
./move_audit.sh[42]: /opt/oracle/logs/audit_clean.log: cannot open [No such file or directory]

Do you think it is file system settings or something related to Linux system configuration?

Last edited by methyl; 06-28-2012 at 06:16 PM.. Reason: please use code tags. Every space character matters in Shell scripting.
# 10  
Old 06-28-2012
It may be something to do with parts of the script you didn't actually post. As Methyl says, the error happens in a line you did not show.
# 11  
Old 06-28-2012
I have found. This part is working. It do remove log file that was touched by me.
The problem is it cannot create a new log file to apend execution information.

Code:
if [ -f $LOGFILE ]; then
  > $LOGFILE
fi

---------- Post updated at 04:44 PM ---------- Previous update was at 04:41 PM ----------

OK. here is the whole script code. remember this script do work on other two or three Linux servers.


Code:
#!/bin/ksh
# This shell performs a full clean audit files  of each DB that is running
export PATH=/opt/oracle/product/11.2.0.2/dbhome_1/bin:/usr/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin
export ORACLE_PATH=/opt/oracle/scripts/sql:$ORACLE_HOME/rdbms/admin
export SCRIPTSDIR=/opt/oracle/scripts
export SCRIPTSLOG=/opt/oracle/logs
export LOGFILE=$SCRIPTSLOG/audit_clean.log
export ORACLE_BASE=/opt/oracle
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P15
export ORATAB=/etc/oratab
export ORACLE_HOME=/opt/oracle/product/11.2.0.2/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH:/usr/contrib/bin
EMAILFILE=`cat $SCRIPTSDIR/emaildba.lst`

if [ -f $LOGFILE ]; then
  rm $LOGFILE
fi

set -A emaillist $EMAILFILE

orasids=`cat /etc/oratab | grep '11.2.0.2/dbhome_1:Y$' | awk -F: '{print $1}' -`

for sid in ${orasids[*]}
do
export ORACLE_SID=$sid
export SYSPW=`cat /opt/oracle/scripts/cron/.sys_pw_$ORACLE_SID`
echo "----------------------------------------------" >> $LOGFILE
echo "Job: Clean Audit files" >> $LOGFILE
echo "Database: $ORACLE_SID \t \t \t \t Hostname: `hostname`" >> $LOGFILE
echo "----------------------------------------------" >> $LOGFILE

sqlplus -s  << EOF
/ as sysdba
@/opt/oracle/scripts/sql/clean_audit.sql
exit
EOF
done

for rec in ${emaillist[*]}
do
mailx -s "Full audit files cleaned on `hostname`" $rec < $LOGFILE
done
exit 0


Last edited by methyl; 06-28-2012 at 06:05 PM.. Reason: please use code tags.
# 12  
Old 06-28-2012
There is a strong hint that this is an oracle process.
Are you logged in as user oracle?

Line 42 (numbered from zero) seems to be the mailx line. Strangely the "same" error message has been displaced by one line.

Please visually check the script for funny characters. This sed just displays normal end-of-line as a dollar sign and makes non-printable characters visible. It does not change the file.
Code:
sed -n l move_audit.sh


Last edited by methyl; 06-28-2012 at 06:14 PM..
# 13  
Old 06-28-2012
I have modified script as this. It has not pumped back any error message. The log file has been created in log directory. Only is the email part didn't work. I will look at and come back to keep you posted.

Code:
#!/bin/ksh
# This shell performs a full clean audit files  of each DB that is running
export PATH=/opt/oracle/product/11.2.0.2/dbhome_1/bin:/usr/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin
export ORACLE_PATH=/opt/oracle/scripts/sql:$ORACLE_HOME/rdbms/admin
export SCRIPTSDIR=/opt/oracle/scripts
export SCRIPTSLOG=/opt/oracle/logs
export LOGFILE=$SCRIPTSLOG/audit_clean.log
export ORACLE_BASE=/opt/oracle
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P15
export ORATAB=/etc/oratab
export ORACLE_HOME=/opt/oracle/product/11.2.0.2/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH:/usr/contrib/bin
EMAILFILE=`cat $SCRIPTSDIR/emaildba.lst`
set -A emaillist $EMAILFILE

orasids=`cat /etc/oratab | grep '11.2.0.2/dbhome_1:Y$' | awk -F: '{print $1}' -`

echo "Job: Removing audit file on `hostname` at `date`" > $LOGFILE
echo " " >> $LOGFILE
echo "-----------------------------------------------------------------" >> $LOGFILE
for sid in ${orasids[*]}
do
export ORACLE_SID=$sid
export SYSPW=`cat /opt/oracle/scripts/cron/.sys_pw_$ORACLE_SID`
echo "----------------------------------------------" >> $LOGFILE
echo "Database: $sid  Hostname: `hostname`" >> $LOGFILE
echo "----------------------------------------------" >> $LOGFILE

sqlplus -s 
/ as sysdba
@/opt/oracle/scripts/sql/clean_audit.sql
done
exit

for rec in ${emaillist[*]}
do
mailx -s "Full audit files cleaned on `hostname`" $rec < $LOGFILE
done
exit 0


Last edited by methyl; 06-28-2012 at 06:28 PM.. Reason: please use code tags. It is so important.
# 14  
Old 06-28-2012
I'm warming to an earlier post which made the sensible suggestion of using touch:
Code:
if [ -f "${LOGFILE}" ]; then
       > "${LOGFILE}"
else
       touch "${LOGFILE}"
fi

Anyway, I am very suspicious of this line:
Quote:
for sid in ${orasids[*]}
I suspect that it is producing at least one null result which means that $LOGFILE never gets created.

As someone who has got through life without ever using a Shell array in a live script, I have absolutely no idea whether this code is sound.

Any posters out there who can check whether that bit of the script works?

I seem to recall adapting an Oracle-supplied script called oraenv.

(At the time of posting I had not seen post #13)

Last edited by methyl; 06-28-2012 at 06:48 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Linux open failed: No such file or directory error

Hi, The below commands works fine on serverB . /etc/profile; cd /export/home/user2/utils/plugin/ ./runme.shHowever, when i run the same commands from serverA it fails $ ssh -q user2@serverB ". /etc/profile; cd /export/home/user2/utils/plugin; ./runme.sh"Output Error: Please find the below... (8 Replies)
Discussion started by: mohtashims
8 Replies

2. Linux

Cannot open shared object file: No such file or directory

Hi, While running tcpdump command on my Fedora 16 machine I am get shared library issue. # tcpdump tcpdump: error while loading shared libraries: libcrypto.so.6: cannot open shared object file: No such file or directory # which tcpdump /usr/software/sbin/tcpdump I have tried... (3 Replies)
Discussion started by: muzaffar.k
3 Replies

3. Solaris

./curl -V showing fatal: libldap.so.5: open failed: No such file or directory

Hi Guys, I am facing this Error bash-2.03$ ./curl -V ld.so.1: curl: fatal: libldap.so.5: open failed: No such file or directory Killed bash-2.03$ while executing ./curl -V in /opt/sfw/bin directory. I am using Sun Solaris 10. which package upgrage can give me this missing... (9 Replies)
Discussion started by: manalisharmabe
9 Replies

4. Shell Programming and Scripting

Awk: cannot open file (No such file or directory)

Hello folks! I am new to Shell and awk scripting. This is my shell script that receives a string as an input from the user from the stdin. #!bin/sh printf "Enter your query\n" read query cmd=`echo $query | cut -f 1 -d " "` input_file=`echo $query | cut -f 2 -d " "` printf $input_file... (10 Replies)
Discussion started by: radiohead_
10 Replies

5. Shell Programming and Scripting

fatal: cannot open file `TNAME' for reading (No such file or directory)

Hi, I am running this command through a shell script and getting the error mentioned in the subject line: testing.awk -f x.txt TNAME My testing.awk file contains something like ++++++++++++++++++ #!/usr/bin/awk -f BEGIN{ TAB_NAME="INSERT_ONE_" ARGV ; } if ( $1=="JAM_ONE" &&... (1 Reply)
Discussion started by: kunwar
1 Replies

6. Red Hat

libodbc.so.1: cannot open shared object file: No such file or directory

We are trying to install third party software on this unix server... Here is the error message we are getting... error while loading shared libraries: libodbc.so.1: cannot open shared object file: No such file or directory It seems like odbc driver is not installed... >rpm -q unixODBC... (1 Reply)
Discussion started by: govindts
1 Replies

7. UNIX for Advanced & Expert Users

how to open a last modified file in a directory

how to directly open a last modified file in a directory? Please help (5 Replies)
Discussion started by: apsprabhu
5 Replies

8. Solaris

Error- ld.so.1: expr: fatal: libgmp.so.3: open failed:No such file or directory

Hi Friends I have a compiler(Sun Forte,I believe) running in my Solaris 9 box. since y'day my development team is finding this error when they compile: ld.so.1: expr: fatal: libgmp.so.3: open failed: No such file or directory I ran a search for this file and found it in one of my file... (2 Replies)
Discussion started by: Hari_Ganesh
2 Replies

9. Programming

libRmath.so: cannot open shared object file: No such file or directory

% locate Rmath /m/backup/backup/lib/R/include/Rmath.h /usr/lib/R/include/Rmath.h % gcc -g -o stand stand.c -I/usr/lib/R/include/ -lRmath -lm % ./stand ./stand: error while loading shared libraries: libRmath.so: cannot open shared object file: No such file or directory What's the trouble... (6 Replies)
Discussion started by: cdbug
6 Replies
Login or Register to Ask a Question