Sponsored Content
Top Forums Shell Programming and Scripting Cannot execute/finish script because of last line syntax error: unexpected end of file/token `done' Post 302655265 by wolf@=NK on Wednesday 13th of June 2012 03:17:01 AM
Old 06-13-2012
Data Cannot execute/finish script because of last line syntax error: unexpected end of file/token `done'

first of all I thought the argument DONE is necessary for all scripts that have or begin with do statements which I have on my script, However, I still don't completely understand why I am receiving an error I tried adding another done argument statement but didn't do any good.

I appreciate some explanation or quick tips/suggestions...

Thanks!

SmilieNon-working, unable to finish/execute script below:Smilie
Code:
#[localuser@localhost ~]$ cat wk7.sh
      1 #!/bin/bash
      2 
      3 #Read tabc.txt
      4 tabc="cat tabc.txt"
      5 
      6 #Make week 7 assignment directory
      7 wk7dir=~/"wk7dir"
      8 
      9 #Prevents duplicates and errors
     10 if [ ! -d $wk7dir ]; then
     11 mkdir $wk7dir
     12 fi
     13 
     14 #Assign appropriate variables from tabc.txt
     15 $tabc | sed -e 's/^\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\(.\{8\}\).*$/\3 \5 \6 \7 \8/' | while read fileuser filesize filedate filename; sed -e 's/^\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\(.\{8\}\).*$/\7/' tabc.txt | sed 's/://' | while read filetime; do
     16 
     17 #Change filesize
     18 dd if=/dev/zero of=$wk7dir/$filename bs=$filesize count=1
     19 
     20 #Create files based on date and filename
     21 touch -d $filedate $wk7dir/$filename
     22 
     23 #Changes file permissions to allow read, write, and execute to all users
     24 find ~/"wk7dir" -type f -exec chmod 755 {} \;;
     25 
     26 ls -lR --time-style="+%Y%m%d" "wk7dir" | sed -e 's/^\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\)/\6/' | while read filedatestamp
     27 
     28 #Modify file time
     29 touch -mt $filedatestamp$filetime $wk7dir/$filename
     30 
     31 done
~                                                                                                                                          ===
 
:(::SEE ERROR OUTPUT BELOW:::wall:
 
[localuser@localhost ~]$ ./wk7.sh
./wk7.sh: line 31: syntax error near unexpected token `done'
./wk7.sh: line 31: `done'


Last edited by wolf@=NK; 06-13-2012 at 04:24 AM..
 

10 More Discussions You Might Find Interesting

1. Solaris

syntax error at line 59: `end of file' unexpected

Hello... I'm trying to run the sshd script, but I keep geting the Syntax errot message . Here's the last few lines on the script. set nu in vi shows 58 lines, but I keep getting error referring to line 59. Any help is appreciated. Thanks, Remi else echo... (4 Replies)
Discussion started by: Remi
4 Replies

2. UNIX Desktop Questions & Answers

line 3: syntax error near unexpected token `('

Hi All I've used UNIX in the past experimenting with commands through terminal but thats about it. Im now currently teaching myself "C". Using a book from the library, the first chapter asks you run and compile your program from a command-line prompt. As you will see the program is very simple,... (4 Replies)
Discussion started by: camzio
4 Replies

3. Shell Programming and Scripting

Help on shell script : syntax error at line 62: `end of file' unexpected

Hi All, I have written a korn script (code pasted below). It is giving the error while debugging "new.sh: syntax error at line 62: `end of file' unexpected". I have re-written the whole code in VI and explored all help related to this error on this Unix forum and tried it. Somehow, I could... (7 Replies)
Discussion started by: schandrakar1
7 Replies

4. Shell Programming and Scripting

for loop not working - syntax error at line 6: `end of file' unexpected

I have a file called test.dat which contains a b I have written a shell script called test.sh for i in `cat test.dat` do echo $i done When i run this script using sh test.sh I get this message - test.sh: syntax error at line 6: `end of file' unexpected What is the... (3 Replies)
Discussion started by: debojyoty
3 Replies

5. Shell Programming and Scripting

syntax error at line 752: `end of file' unexpected

Hi, I'm having a syntax error at line 752: `end of file' unexpected. However, i didn't make any changes on line 752. I just inserted a new code in an existing program. Can anyone please check if there is something wrong with my code: if then lline=`tail -5 $badfile` ... (3 Replies)
Discussion started by: chryz
3 Replies

6. Shell Programming and Scripting

./TRUNCATE-PS_TXN.sh: line 54: syntax error: unexpected end of file

Hi All , My below script is for chacking vaule and then trucating table : ___________ test4@aceuatcs04:/u01/test4/SOLID/Testscript>cat TRUNCATE-PS_TXN.sh #-------------------------------------------------------------------- # Created by:Kaushlesh Yadav # Generated on: 15/07/2010 # Job... (4 Replies)
Discussion started by: kaushelsh168
4 Replies

7. Shell Programming and Scripting

line 15: syntax error: unexpected end of file

Hi all, I am very new to programming and even newer to this forum as well, so I apologize if this should have been in the Newbie category, but... I am currently trying to figure out Shell Scripting and am running into problems early. Not having taken any kind of programming class, I am not even... (2 Replies)
Discussion started by: ccorder22
2 Replies

8. Red Hat

sh: module: line 1: syntax error: unexpected end of file

Hi, We have installed linux6(RHEL) OS and installed datastage application on that. First time installation worked fine and our all services related to datastage was up and running. When we stopped the datastage and restarted its giving below error while restart:- ./uv -admin -start DataStage... (0 Replies)
Discussion started by: prasson_ibm
0 Replies

9. Shell Programming and Scripting

Del: line 13: syntax error: unexpected end of file

1 echo -e "Enter a filename" 2 read filename 3 if 4 then 5 echo -e "do you want to delete?" 6 read answer 7 if 8 then rm myfirst 9 else 10 echo -e "file not deleted" 11 fi 12 exit0 (1 Reply)
Discussion started by: Speedy
1 Replies

10. Programming

Sh: -c: line 0: syntax error near unexpected token `(' how to resolve this

Below query is not working for me. Please help me on this DATA EXCLUDE STATEMENT: TABLE:\"LIKE \'%\_HISTORY\'\", TABLE:\"LIKE \'%\_HIST\'\", TABLE:\"in \(select tname from tab where REGEXP_LIKE(TNAME,\'\_H$\'\))\", TABLE:\"LIKE \'%\_LOG\'\", TABLE:\"LIKE \'DW\_%\'\", TABLE:\"LIKE... (1 Reply)
Discussion started by: princy
1 Replies
DH_INSTALLDEB(1)						     Debhelper							  DH_INSTALLDEB(1)

NAME
dh_installdeb - install files into the DEBIAN directory SYNOPSIS
dh_installdeb [debhelperoptions] DESCRIPTION
dh_installdeb is a debhelper program that is responsible for installing files into the DEBIAN directories in package build directories with the correct permissions. FILES
package.postinst package.preinst package.postrm package.prerm These maintainer scripts are installed into the DEBIAN directory. Inside the scripts, the token #DEBHELPER# is replaced with shell script snippets generated by other debhelper commands. package.triggers package.shlibs These control files are installed into the DEBIAN directory. package.conffiles This control file will be installed into the DEBIAN directory. In v3 compatibility mode and higher, all files in the etc/ directory in a package will automatically be flagged as conffiles by this program, so there is no need to list them manually here. package.maintscript Lines in this file correspond to dpkg-maintscript-helper(1) commands and parameters. Any shell metacharacters will be escaped, so arbitrary shell code cannot be inserted here. For example, a line such as "mv_conffile /etc/oldconffile /etc/newconffile" will insert maintainer script snippets into all maintainer scripts sufficient to move that conffile. A versioned Pre-Dependency on dpkg is needed to use dpkg-maintscript-helper(1). An appropriate Pre-Dependency is set in ${misc:Pre-Depends} ; you should make sure to put that token into an appropriate place in your debian/control file. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 8.9.0ubuntu2.1 2012-06-12 DH_INSTALLDEB(1)
All times are GMT -4. The time now is 11:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy