Home » Infrastructure » Unix » Looping problem
Looping problem [message #304581] Wed, 05 March 2008 13:16 Go to next message
shree_z
Messages: 75
Registered: February 2008
Member
I have a shell script which selects filenames of certain pattern say A*.txt and send it to a concurrent program.
If the concurrent program is unsuccessful it has to fetch the next file .

If the concurrent program is successful, then the file is archived.

Here is a part of the code.



ls -lrt A*.txt | awk '{print $9}' | while read fname
do
sqlplus -S <<-END-OF-STD-INPUT-MARKER
  $db_user/$db_pass
var retval number;
DECLARE
v_retcode varchar2(100);
v_errbuf varchar2(100);
v_filepath varchar2(100);
v_fname varchar2(100);
BEGIN
v_filepath := '$dir';
v_fname := '$fname' ;
ECNI.PROCESS_INBOUND(v_retcode
                            ,v_errbuf
			    ,v_filepath
                            ,v_fname
                            );
:retval := v_errbuf;
END;
/
exit :retval;
END-OF-STD-INPUT-MARKER
if [ $? -ne 0 ]
then
  echo "Error while Importing "
  exit 1
else
mv $fname $archdir
echo The file $fname was successfully imported and moved from $dir to $archdir
fi


Here the problem is once the concurrent program fails with a filename, the shell script is no longer going to the next file and sending it to the concurrent program.

How can I resolve this?

Please help,

Thanks in advance
Re: Looping problem [message #304582 is a reply to message #304581] Wed, 05 March 2008 13:22 Go to previous message
shree_z
Messages: 75
Registered: February 2008
Member
Oh I got the solution!!

it was the "exit 1"!!

I removed it.. Now the program is fine

Thanks
Previous Topic: shell script error - passing parameters to PL/SQL (merged)
Next Topic: UNIX
Goto Forum:
  


Current Time: Thu Nov 21 22:58:27 CST 2024