Problems executing SQL Plus sessions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problems executing SQL Plus sessions
# 1  
Old 06-06-2005
Problems executing SQL Plus sessions

If I execute this script:

$ORACLE_HOME/bin/sqlplus -s <<EOF > oracle.log
$DB_id/$DB_pswd@$DB_server
start test.sql
EOF
the sql script executes with no errors.


IF I execute the following script:

UsedSpace=`df -k . | awk '{print $5 }'| tail -1 | cut -d"%" -f1`

if [ $UsedSpace -ge 50 ]
then
cd /ford/thishost/u/rct/www.80/crid/crid_new/cronjobs
$ORACLE_HOME/bin/sqlplus -s <<EOF > oracle.log
$DB_id/$DB_pswd@$DB_server
start test.sql
EOF
fi
I receive a syntax error. The syntax error must be the way I am wrapping the if clause because the line starting UsedSpace works fine. What am I doing wrong? Thanks for your help.
# 2  
Old 06-06-2005
I have never seen the "Start" usage before. I would replace "start test.sql" with @test.sql (supply a path to the script if need be)
# 3  
Old 06-06-2005
Thanks but I am still getting syntax errors

I have replace "start" with "@". I am still getting syntax errors. Is there anybody else that can help me?
# 4  
Old 06-06-2005
What is the actual syntax error thrown? What is UsedSpace set to after this line is executed
Code:
UsedSpace=`df -k . | awk '{print $5 }'| tail -1 | cut -d"%" -f1`

Also (not that this will fix your issue but..) this would be cleaner syntax and it allows variables to be nested.

UsedSpace=$(df -k . | awk '{print $5 }'| tail -1 | cut -d"%" -f1)
# 5  
Old 06-06-2005
$ORACLE_HOME/bin/sqlplus $DB_id/$DB_pswd@$DB_server <<EOF
.....
EOF
# 6  
Old 06-06-2005
FWIW -
start comes the afi/ufi pre-Sqlplus versions of Oracle. It is exactly the same as @, just from version 2 of Oracle.
# 7  
Old 06-06-2005
Answer to value in variable $UsedSpace

The value of this variable is 80. I have tried all suggestions, but I am still getting a syntax error.

test.sh: syntax error at line 34: `end of file' unexpected

Line 34 goes beyond the last line in file test.sh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Executing SQL's in parallel

Hi Folks, I have requirement to pull a bunch of SQL's from a table in DB and execute them in parallel and update the status of each query as and when they complete. Can you please help me with ideas on how this can be achieved? create table list_of_sql ( id number, full_sql... (3 Replies)
Discussion started by: member2014
3 Replies

2. Shell Programming and Scripting

Parallel SQL sessions in shell script

i have 3 sqls , sql 1 and sql 2 shuld run in parallel , but sql 3 should run after completion f sql1 nd sql2, my code is as below, please suggest the changes sqlplus username1/password1@DB1 @sql >> log1 & sqlplus username2/password2@DB2 @sql2 >> log1 & how can i execute the... (7 Replies)
Discussion started by: only4satish
7 Replies

3. Homework & Coursework Questions

Problems executing script

Hi, I'm a complete novice to Linux and UNIX. I'm having trouble getting a script to execute properly. I did a similar script earlier in the semester with no problems. For whatever reason I can't get this one to work. Any help would be greatly appreciated as I'm completely lost and frustrated at... (5 Replies)
Discussion started by: Lindy70
5 Replies

4. Shell Programming and Scripting

Help with executing parallel sessions for same shell script with different but fixed parameters

Hi Experts, There is a shell script that accepts positional parameter between 1-25 to execute case statement of script depending upon the parameter passed. Now I need to run all the 25 sessions parallely. In each option of case statement it is connecting with sqlplus and executing a select... (11 Replies)
Discussion started by: Opamps123
11 Replies

5. Shell Programming and Scripting

Executing sql statement from .sh file

Hi, How to execute sql statements from the .sh file ?? Means, when we run .sh file then the sql statements within it should be get executed one by one from the sqlplus With Regards (3 Replies)
Discussion started by: milink
3 Replies

6. Shell Programming and Scripting

need some help in executing sql

i am stuck with a problem ... i have a shell script that gets the file name as input and performs the following operation... it runs through a for loop inside from which i connect to sqlplus and run a procedure that creates a number of tables .. there is no space in my server so we have made... (0 Replies)
Discussion started by: sais
0 Replies

7. Shell Programming and Scripting

Executing pl/sql using sqlplus on unix

Hi to all, I have a endday.sh file. And I execute this like "sh endday.sh" from command prompt. In endday.sh file it writes: sqlplus temp/temp@data @run.sql& echo $!>>pid.txt However my aim is not to put the pid into pid.txt but I need to insert the pid into an oracle table using sqlplus.... (1 Reply)
Discussion started by: maverick1234
1 Replies

8. UNIX for Advanced & Expert Users

Executing pl/sql using sqlplus on unix

Hi to all, I have a endday.sh file. And I execute this like "sh endday.sh" from command prompt. In endday.sh file it writes: sqlplus temp/temp@data @run.sql& echo $!>>pid.txt However my aim is not to put the pid into pid.txt but I need to insert the pid into an oracle table using sqlplus.... (1 Reply)
Discussion started by: maverick1234
1 Replies

9. Programming

Executing pl/sql using sqlplus on unix

Hi to all, I have a endday.sh file. And I execute this like "sh endday.sh" from command prompt. In endday.sh file it writes: sqlplus temp/temp@data @run.sql& echo $!>>pid.txt However my aim is not to put the pid into pid.txt but I need to insert the pid into an oracle table using sqlplus.... (1 Reply)
Discussion started by: maverick1234
1 Replies

10. Shell Programming and Scripting

Script executing sql query

Hello, I have a sh script excuting a sql query through sqlplus. I am having trouble making my date equal to the date of the server time in the sql script. How can i call the server date from my query? Thanks (2 Replies)
Discussion started by: kingluke
2 Replies
Login or Register to Ask a Question