![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| oracle connection from shell script | DILEEP410 | Shell Programming and Scripting | 4 | 07-01-2009 03:19 AM |
| sybase connection through shell-script | Amitabh | UNIX for Dummies Questions & Answers | 9 | 04-10-2009 11:34 PM |
| Logging into oracle or SQL from shell script | manirsendhil | Shell Programming and Scripting | 2 | 04-10-2007 12:46 AM |
| run shell script from oracle store procedure | arnabb4u | Shell Programming and Scripting | 8 | 08-16-2006 01:16 PM |
| Shell script on Oracle hot backup got an error | oradbus | UNIX for Advanced & Expert Users | 1 | 01-03-2006 12:35 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi all,
I am having problem with a shell script. I have a couple of csv files. The shell script will do some operation on them, create a sql file which will then be called by sqlplus. The problem is to gracefully exit sqlplus at the end of every operation as I do not want to hang on to the connection. But I am getting an error the way I am doing it (see code). Can someone pl. help? #!/bin/ksh if [ -e *.csv ] then for csvfile in *.csv do echo "set feedback off" > temp.sql echo "set echo off" >> temp.sql echo "delete from test_table;" >> temp.sql awk -F, -f parse.awk $csvfile >> temp.sql echo "commit;" >> temp.sql rm -f $csvfile sqlplus -S uanme/pwd@mydb @temp.sql > test.log << endsqlplus done endsqlplus exit 0 fi |
|
||||
|
i think you could append exit at the end of the .sql file
and then just execute the .sql file by using: sqlplus -S uanme/pwd@mydb @temp.sql > test.log in your loop, you would probably want to rename your log file by concatenating the csvfile to it, just an idea hop it helps i.e. #!/bin/ksh if [ -e *.csv ] then for csvfile in *.csv do echo "set feedback off" > temp.sql echo "set echo off" >> temp.sql echo "delete from test_table;" >> temp.sql awk -F, -f parse.awk $csvfile >> temp.sql echo "commit;" >> temp.sql echo "exit;" >> temp.sql rm -f $csvfile sqlplus -S uanme/pwd@mydb @temp.sql > test.$csvfile.log done exit 0 fi |
|
||||
|
Try this.
#!/bin/ksh if [ -e *.csv ] then for csvfile in *.csv do echo "set feedback off" > temp.sql echo "set echo off" >> temp.sql echo "delete from test_table;" >> temp.sql awk -F, -f parse.awk $csvfile >> temp.sql echo "commit;" >> temp.sql echo "exit;" >> temp.sql rm -f $csvfile sqlplus -S uanme/pwd@mydb <<EOF @temp.sql exit 0 EOF done fi Good Luck! ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|