I think it's better doing it this way instead of calling sqlplus for each sql file:
autoload.sh
#!/bin/sh
# create runall.all file
touch runall.all
# copy paths to sql files in current directory in the runall.all file
# format: @/path/to/sql/file
for i in *.sql
do
echo "@`pwd`/$i" >> runall.all
done
# rename runall.all to runall.sql
mv runall.all runall.sql
# append "EXIT" to every sql file to avoid a hang
for i in *.sql
do
echo EXIT >> $i
done
# start sql
sqlplus uname/password@sid @`pwd`/runall.sql
$ ls
autoload.sh load-002.sql load-004.sql
load-001.sql load-003.sql load-005.sql
$ sh autoload.sh
sqlplus: not found
$ ls
autoload.sh load-002.sql load-004.sql runall.sql
load-001.sql load-003.sql load-005.sql
$ cat runall.sql
@/usr/home/myuser/sql/load-001.sql
@/usr/home/myuser/sql/load-002.sql
@/usr/home/myuser/sql/load-003.sql
@/usr/home/myuser/sql/load-004.sql
@/usr/home/myuser/sql/load-005.sql
EXIT
$
Not only for sqls i need to execute some utilities
so i need to read the all the file names. and in for loop i will pass individual file name as a parameter to that utility.