Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Unexpected eof error

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-10-2008
thana thana is offline
Registered User
 
Join Date: Jan 2008
Last Activity: 7 November 2010, 11:58 PM EST
Posts: 67
Thanks: 2
Thanked 0 Times in 0 Posts
Unexpected eof error

Hi,
I am newbie and am just trying to connect to oracle from shell script ,,,but I am getting the following error

./prog.sh: line 20: syntax error: unexpected end of file

The scripts is :

#!/bin/bash
O=$IFS; IFS=",";
while read a b c d
do
echo $c
sqlplus -s training1/training1 << EOF
set serveroutput on;
BEGIN
DBMS_OUTPUT.PUT_LINE('IN SQL');
END;
/
quit;
EOF
done > file.txt

IFS=$O;


Can anyone help me
Sponsored Links
    #2  
Old Unix and Linux 01-10-2008
DukeNuke2's Unix or Linux Image
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
 
Join Date: Jul 2006
Last Activity: 23 May 2015, 2:52 AM EDT
Location: Berlin, Germany
Posts: 5,492
Thanks: 61
Thanked 245 Times in 238 Posts
insert a "set -xv" in the second line of your script an run it. post the output from screen here...
Sponsored Links
    #3  
Old Unix and Linux 01-10-2008
thana thana is offline
Registered User
 
Join Date: Jan 2008
Last Activity: 7 November 2010, 11:58 PM EST
Posts: 67
Thanks: 2
Thanked 0 Times in 0 Posts
This is the output I got


-bash-3.00$ ./prog.sh
O=$IFS; IFS=",";
+ O='
'
+ IFS=,

while read a b c d
do
echo $c
sqlplus -s training1/training1 << EOF
./prog.sh: line 19: syntax error: unexpected end of file
    #4  
Old Unix and Linux 01-10-2008
rein rein is offline
Registered User
 
Join Date: Dec 2004
Last Activity: 31 January 2011, 2:32 PM EST
Location: Zürich
Posts: 151
Thanks: 0
Thanked 1 Time in 1 Post
I've noticed there's a space between << and EOF. Try removing it:


Code:
#!/bin/bash
O=$IFS; IFS=",";
while read a b c d
do
echo $c
sqlplus -s training1/training1 <<EOF
set serveroutput on;
BEGIN
DBMS_OUTPUT.PUT_LINE('IN SQL');
END;
/
quit;
EOF
done > file.txt

IFS=$O;

See if that helps.
Sponsored Links
    #5  
Old Unix and Linux 01-10-2008
thana thana is offline
Registered User
 
Join Date: Jan 2008
Last Activity: 7 November 2010, 11:58 PM EST
Posts: 67
Thanks: 2
Thanked 0 Times in 0 Posts
I have tried but still its comming.
But the following code works

#!/bin/sh
sqlplus -s training1/training1 << EOF
set serveroutput on;
BEGIN
DBMS_OUTPUT.PUT_LINE('File Open Error');

END;
/
EOF
Sponsored Links
    #6  
Old Unix and Linux 01-10-2008
thana thana is offline
Registered User
 
Join Date: Jan 2008
Last Activity: 7 November 2010, 11:58 PM EST
Posts: 67
Thanks: 2
Thanked 0 Times in 0 Posts
the last done statement is as

done < file.txt
Sponsored Links
    #7  
Old Unix and Linux 01-11-2008
thana thana is offline
Registered User
 
Join Date: Jan 2008
Last Activity: 7 November 2010, 11:58 PM EST
Posts: 67
Thanks: 2
Thanked 0 Times in 0 Posts
Ohhh I got it finally..but still count not locate the error in the first code....
Can anyone point it out..Linux

#!/bin/bash
O=$IFS; IFS=",";
while read a b c d
do
echo $c
sqlplus -s training1/training1 <<EOF
set serveroutput on;
BEGIN
DBMS_OUTPUT.PUT_LINE('IN SQL');
END;
/
quit;
EOF
done < a
IFS=$O;
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
bash script error - syntax error: unexpected end of file smenago Shell Programming and Scripting 6 04-26-2012 08:35 AM
Getting unexpected error NirajThakar Shell Programming and Scripting 5 07-25-2011 10:29 AM
sed error : Syntax error: redirection unexpected phpfreak Shell Programming and Scripting 3 12-04-2008 04:19 AM
unexpected error helpme2008 UNIX for Dummies Questions & Answers 2 05-04-2008 02:08 PM
awk Shell Script error : "Syntax Error : `Split' unexpected Herry UNIX for Dummies Questions & Answers 2 03-17-2008 11:16 AM



All times are GMT -4. The time now is 03:16 PM.