Visit Our UNIX and Linux User Community

0403-016 Cannot find or open the file in If Statement

Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers 0403-016 Cannot find or open the file in If Statement
# 1  
Old 03-18-2019
0403-016 Cannot find or open the file in If Statement


I am comparing the number of records in the .bad record from sql loader, if it is higher than the number passed in as an argument, the program should exit. However, I constantly receive the error "
0403-016 Cannot find or open the file.

" on the line with the if statement "elif [ $bad_record_count <= $error_limit ];". The code is below and error_limit=$1. Any help is appreciated.

if [[ $chksanret = 0 ]]; then
   sqlldr CONTROL=$LOAD_HOME/lndcntl/mrkdwndly.ctl LOG=$LOAD_HOME/loadresults/mrkdnasapbar.log  \
      BAD=$LOAD_HOME/loadresults/mrkdnasapbaz.bad DATA=$LOAD_HOME/$fnamem     \
      USERID=$OSLDR ERRORS=999 DISCARD=$LOAD_HOME/loadresults/mrkdnasaptoss.dis \
   retcode=`echo $?`
   bad_record_count=$(< $LOAD_HOME/loadresults/mrkdnasapbaz.bad wc -l)
   if [[ $retcode = 0 ]]
   elif [ $bad_record_count <= $error_limit ];
     exit 12
   exit $chksanret

Last edited by RudiC; 03-19-2019 at 06:52 AM..
# 2  
Old 03-18-2019
It's wrong
elif [ $bad_record_count <= $error_limit ];

elif [ $bad_record_count -le $error_limit ];

and else
if [[ $chksanret = 0 ]]

if [ $chksanret = 0 ]

if [ $chksanret -eq 0 ]

if [[ $chksanret == 0 ]]

--- Post updated at 21:30 ---

I hope this is not the whole file and there is a final "fi"
This User Gave Thanks to nezabudka For This Post:
# 3  
Old 03-18-2019
retcode=`echo $?`

works but is bad style. Should be simply

This User Gave Thanks to MadeInGermany For This Post:
# 4  
Old 03-19-2019
Despite nezabudka's and MadeInGermany's comments being correct they don't explain the error message. It comes from the shell interpreting the < as the redirection operator for stdin, and it doesn't find the file named the $error_limit's value. Escaping it would have helped circumvent that error, but had immediately stumbled over the next one: <= is not an accepted operator (in bashat least - you didn't mention the shell you use), use ! ... \> in lieu. Be aware that either of these compare values lexicographically using the current locale, so 145 would be considered less than 87, for instance. That's where nezabudka's proposals to use integer / numerical operators (like -le) come into play.
This User Gave Thanks to RudiC For This Post:

Previous Thread | Next Thread
Test Your Knowledge in Computers #210
Difficulty: Easy
Routing protocols like OSPF calculate the shortest route to a destination through the network based on a computer algorithm.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] 0403-057 Syntax error for if statement

I am getting the following error when I am running a script in ksh when trying to execute an if statement comparing two numerical values 1.5321e+08: 0403-057 Syntax error Below is my code snippet. #!/bin/ksh set -x TODAY=$(date +%y%m%d) for file in $(ls -rt *.log | tail... (11 Replies)
Discussion started by: kiran1112
11 Replies

2. UNIX for Dummies Questions & Answers

Statement to find if an entry exists in a file

I need to check if an entry input by the user is in a file. If so, I need to run a command, and if it does not exist then it should output entry does not exist. So I have so far... echo "Enter record:" read record //command || //command Can I use an if statement to do this? (3 Replies)
Discussion started by: itech4814
3 Replies

3. Shell Programming and Scripting

Nothing is getting displayed on browser while using open statement

Hi, I have the below script which is working fine on cmd line, but nothing gets displayed on browser. There is no permission issue. If i remove the open statement and print some other data. Its working fine on browser. Kindly help. #!c:/perl/bin/perl use Win32::ODBC; use CGI ':standard';... (19 Replies)
Discussion started by: miteshpant
19 Replies

4. Shell Programming and Scripting

Newbie.. Find if a file exists and open, if not create the desired file..

Hey all, I'm brand new to script writing, I'm wanting to make a script that will ask for a file and then retrieve that file if it exists, and if it doesn't exist, create the file with the desired name, and I'm completely stuck.. so far.. #! bin/bash echo "Enter desired file" read "$file" if ... (5 Replies)
Discussion started by: Byrang
5 Replies

5. SCO

Error: msgcnt 1 vxfs: mesg 016: vx_ilisterr - / file system error reading

Hello... i got an error in my SCO OpenServer 6. the error is: msgcnt 1 vxfs: mesg 016: vx_ilisterr - / file system error reading inode 373 Can anyone help me? (1 Reply)
Discussion started by: AndryMB
1 Replies

6. Shell Programming and Scripting

For loop find statement file name manipulation

for i in `find . -name "*.BEFORE_DISASTER_RECOVERY"`;do dir_name=`dirname $i`;file_name=`basename $i`;cd $dir_name;mv $file_name (STUCK HERE) ;pwd;cd $BASE_DIR;done Okay, so I was able to get to this point. As you can see, I have a small for loop that searches for any files with the string... (5 Replies)
Discussion started by: cbo0485
5 Replies

7. Shell Programming and Scripting

Script Error: 13192.sumr: 0403-016 Cannot find or open the file.

Hello, i am familiar enough with unix to do some damage but thats about it. We have a set of RS/6000 43P Model 150's running AIX for our Catia V4 programmers. back in the 90's a script was written to automate the conversion of files into machine code. that script has started giving us... (0 Replies)
Discussion started by: jgruenwald
0 Replies

8. Solaris

Error Message: find: cannot open /: Stale NFS file handle

I am using the "find" command below and it respond with the error message " find: cannot open /: Stale NFS file handle" what does it mean? what can I do about it? Need advice, thanks. below are the command that I enter, the respond and the error message: root@ScripServer:/# find / -name... (1 Reply)
Discussion started by: ezsurf
1 Replies

9. UNIX for Dummies Questions & Answers

0403-015 - Cannot access a required executable file. It is in use.

How is this error resolved please? I'm just trying to run a shell script and am getting this error. All file permissions are fine. Thanks (0 Replies)
Discussion started by: miwinter
0 Replies

10. Shell Programming and Scripting

getting error 0403-016 Cannot find or open the file while reading a long line

Hi, I have an requirement of reading a long line of 7000 chars and cutting it iam doing this : while read -r x do echo $x ......... done < `cat filename` when iam doing this it is giving me "0403-016 Cannot find or open the file." Can anyone let how this can be done. (2 Replies)
Discussion started by: karthee
2 Replies

Featured Tech Videos