Can not determine end-of-file error


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Can not determine end-of-file error
# 8  
Old 02-16-2017
Yes. That is an issue. The here-document started with the line:
Code:
       sqlplus /nolog <<EOF

does not end until there is a line that just contains the three characters EOF and a line terminating <newline> character. If you started the here document with <<-EOF instead of <<EOF, the here-document could be terminated by a line just containing zero or more leading <tab> characters, the three characters EOF, and a line terminating <newline> character. Any <space> characters before the here-document terminator string will cause that line to included in the here-document and keep it from being recognized as the terminator.
This User Gave Thanks to Don Cragun For This Post:
# 9  
Old 02-16-2017
Try:-

Remove the indent on line #12 to place the EOF token at the beginning of the line.
# 10  
Old 02-17-2017
ok.. to test further, I've removed all of the spaces and used <<EOF>> tag as suggested. I'v also used db connection login/pw.. this time it didn't prompt end-of-file error.. but file rename didn't work..
if I could I've two follow-up questions -

Code:
#!/bin/sh
#. /u01/app/oracle/local/bin/cron_env_$ORACLE_SID
file_name='./services.dat'
if [ -f $file_name ]; then
echo "file found " $file_name
sqlplus /nolog <<-EOF >./tst.log
connect test/test
set feedback off
set echo on
@./glspreltr.sql
exit
EOF
fi
mv $file_name $file_name_%m%d%Y
echo $file_name

output:
perseus.gasleak(/tmp/v_tst)% ./f2.sh
file found ./services.dat
./services.dat


qes1: in the file rename some how did not like "%m%d%Y" format.. why?
qes2: is there way to determine when the file was written mm-dd-yy-hh-mm and use that for the rename. if so, please suggest how to do that.
Can not determine end-of-file error-file_rn_issuepng
# 11  
Old 02-17-2017
Quote:
Originally Posted by V1l1h1
qes1: in the file rename some how did not like "%m%d%Y" format.. why?
qes2: is there way to determine when the file was written mm-dd-yy-hh-mm and use that for the rename. if so, please suggest how to do that.
As you are using /bin/sh you need to use the date program:

Code:
mv "${file_name}" "${file_name}"_$(date +'%m%d%Y')

You can get hold of the access time, modification time and change time of a file using stat if you have it:
Code:
stat -c "%y" "${file_name}"

Gnu date also has a switch to show the last modification timestamp of a file:
Code:
date -r "${file_name}"

which is probably the closest you will get on a Linux/Unix system to the creation time. So you could possibly use:
Code:
mv "${file_name}" "${file_name}"_$(date -c "${file_name}"  +'%m%d%Y')


Last edited by apmcd47; 02-17-2017 at 10:34 AM.. Reason: missed underscore in renamed filename
# 12  
Old 02-17-2017
Quote:
Originally Posted by V1l1h1
qes2: is there way to determine when the file was written mm-dd-yy-hh-mm and use that for the rename. if so, please suggest how to do that.
Not really, not reliably, especially with only two-digit years.
# 13  
Old 02-17-2017
yes I'm using "/bin/sh "

it won't let me use stat .. it prompts "not found..
also, I could not use switch with stat and also -r switch with date
the closet I can try was that
Code:
mv "${file_name}" "${file_name}"_`date +'%m%d%Y'`

at least this time renamed the file with date stamp..

Appreciate all your help. It is helping me learn shell scripting
# 14  
Old 02-22-2017
Quote:
Originally Posted by V1l1h1
yes I'm using "/bin/sh "

it won't let me use stat .. it prompts "not found..
also, I could not use switch with stat and also -r switch with date
the closet I can try was that
Code:
mv "${file_name}" "${file_name}"_`date +'%m%d%Y'`

at least this time renamed the file with date stamp..

Appreciate all your help. It is helping me learn shell scripting
You could try my general purpose date script written in perl which supports many GNU date like options.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

IF section problem. syntax error: unexpected end of file error

Hello, I have another problem with my script. Please accept my apologies, but I am really nooby in sh scripts. I am writing it for first time. My script: returned=`tail -50 SapLogs.log | grep -i "Error"` echo $returned if ; then echo "There is no errors in the logs" fi And after... (10 Replies)
Discussion started by: jedzio
10 Replies

2. Shell Programming and Scripting

Unexpected End Of File Error

Hi guys, I am new to BASH scripting and I was wondering if anyone could have a look at this code and explain to me why I am getting an Unexpected End of File Error ? If you can that would be great / much appreciated! THANKS! #!/bin/bash USER="" PASS="" if ; then echo "You need to set... (1 Reply)
Discussion started by: spooke
1 Replies

3. Shell Programming and Scripting

Unexpected end of file error

Hi , I am new to Unix and this is my first shell script . I am facing "unexpected end of file error" while executing my code . tried removing blank spaces Unable to trace out the error . PLease help !!! #!/bin/sh echo hello if ] echo hi then var=`cat liq_table_nm.txt` ... (6 Replies)
Discussion started by: sen180185
6 Replies

4. Shell Programming and Scripting

`end of file' unexpected error

When I am executing my really simple shell script below, I got an error: `end of file' unexpected. Script is suppose to print out a list of supplied parameters. Here is my script: #!/bin/sh a=$# #number or parameters b=0 #starting counter while do b=`expr $b + 1` echo... (9 Replies)
Discussion started by: alexstar
9 Replies

5. Shell Programming and Scripting

error unexpected end of file

Sometimes while unziping some files i got an error and the further unziping stopped.might be other files are able to be unzip.i.e gunzip a.Z b.Z c.Z gunzip: a.Z: unexpected end of file it found an error on a.Z and stopped but b.Z and C.Z might be correct. why this error comes and is... (2 Replies)
Discussion started by: malikshahid85
2 Replies

6. Shell Programming and Scripting

syntax error: unexpected end of file

Hi, I am newbie to UNIX scripting. I am facing this error "syntax error: unexpected end of file" while executing the following script: ------ a=$1 if then sqlplus -s prospect_stg/prospect_stg@mdmpt <<END insert into bckup_marc_parameter_lookup select * from... (6 Replies)
Discussion started by: boopathyvasagam
6 Replies

7. Shell Programming and Scripting

syntax error: unexpected end of file

Hi, I have problem in constructing "IF" condition. The below code throws "tst.sh: line 10: syntax error: unexpected end of file" #!/bin/ksh test=9 echo $test if ] then echo "in" fi echo "end" exit 0 Actually, i want to check whether the variable $test is empty or null. ... (5 Replies)
Discussion started by: tinku
5 Replies

8. Shell Programming and Scripting

unexpected end of file error

When I run the following script: #! /bin/bash for var in CA CC CD CT EC PC do cat << EOF > ${var}_full.dat echo T ${var}_high echo C age echo C sex echo C ht echo C WT_lg EOF cat << EOF > ${var}_agesex.dat ... (4 Replies)
Discussion started by: polly_falconer
4 Replies

9. Shell Programming and Scripting

unexpected end of file error

hi, i am trying to connect to sqlplus in an 'if block' from the script. it is giving unexpected end of file error. and it works fine if it is out of 'if block'. if anybody have idea on this, can you please help me to solve the error ? piece of code is given below. if then... (11 Replies)
Discussion started by: vinayakatj56
11 Replies

10. Shell Programming and Scripting

End of file unexpected error

Hi, I am new to unix. I have written a script whenever i am giving sh filename.sh its prompting unexpected end of file in line number 40 in that line i have echo statement what do i need to do thanks in advance (5 Replies)
Discussion started by: hamsa
5 Replies
Login or Register to Ask a Question