Problems executing SQL Plus sessions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problems executing SQL Plus sessions
# 8  
Old 06-06-2005
Quote:
Originally Posted by mh53j_fe
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
the matching/ending EOF marker should have no leading spaces/tabs in front of it.

Pls post what you're trying.
# 9  
Old 06-06-2005
Here is what I am trying to do

When our end-users run reports, we save a copy of the report on our web server. I want to create a shell script that is executed by CRON to occasionally clean out reports and free up disk space.
Here is the report.

#!/bin/sh
UsedSpace=`df -k . | awk '{print $5 }'| tail -1 | cut -d"%" -f1`
##the cut -d"%" strips out the % sign.

if [ $UsedSpace -ge 50 ]
then
# ls -l >> $logfile
# $ORACLE_HOME/bin/sqlplus $DB_id/$DB_pswd@$DB_server <<SQLPLUS
$ORACLE_HOME/bin/sqlplus -s <<SQLPLUS > oracle.log
$DB_id/$DB_pswd@$DB_server
spool test1.log
select to_char(sysdate,'YYYYMMDDHHMMSS') FROM dual;
spool off
SQLPLUS
fi

When I execute this script from the command line, I get the following error: test.sh: syntax error at line 34: `end of file' unexpected

If I remove the If/end if lines, the scrip runs fine. Any thoughts?
# 10  
Old 06-06-2005
Correction - here is what I am trying to do

When our end-users run reports, we save a copy of the report on our web server and to a db table. I want to create a shell script that is executed by CRON to occasionally clean out reports and free up disk space and remove the record from the db.
Here is the report.

#!/bin/sh
UsedSpace=`df -k . | awk '{print $5 }'| tail -1 | cut -d"%" -f1`
##the cut -d"%" strips out the % sign.

if [ $UsedSpace -ge 50 ]
then
# ls -l >> $logfile
# $ORACLE_HOME/bin/sqlplus $DB_id/$DB_pswd@$DB_server <<SQLPLUS
$ORACLE_HOME/bin/sqlplus -s <<SQLPLUS > oracle.log
$DB_id/$DB_pswd@$DB_server
spool test1.log
execute RemoveReports;
spool off
SQLPLUS
fi

When I execute this script from the command line, I get the following error: test.sh: syntax error at line 34: `end of file' unexpected

If I remove the If/end if lines, the scrip runs fine. Any thoughts?

mh53j_fe
View Public Profile
Find all posts by mh53j_fe
Add mh53j_fe to Your Buddy List




« Previous Thread
# 11  
Old 06-06-2005
Quote:
Originally Posted by mh53j_fe
If I remove the If/end if lines, the scrip runs fine. Any thoughts?
« Previous Thread
first, Is the RemoveReport a stored procedure or function? If it is you can use the execute command otherwise you would have to use either 'start 'or '@'RemoveReports to indicate the sql file that you are trying to run.

Second.
open your shell in vi an do a set list. If you find any spaces at the end of the lines after the sqlplus invocation remove those spaces and give it a try.
# 12  
Old 06-06-2005
Thank you jerardfjay!!!!

I do use the vi editor, and when i turned on set list, Voila!
I took out all the white spaces wrapped around the sql statements and the script ran fine.

Thanks to you and all the others that have replied to my requests today!

Dave
# 13  
Old 06-13-2005
I think if you simply add a - (minus) after the << it should ignore any tabs and whitespace it finds.

<<-SQPLUS
...
SQLPLUS
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