Sponsored Content
Full Discussion: Syntax error in script
Top Forums Shell Programming and Scripting Syntax error in script Post 302099542 by KindHead on Tuesday 12th of December 2006 09:24:16 PM
Old 12-12-2006
Syntax error in script

I get this error when I try to run my script

(BTW, this is a simple script I am supposed to write for my class)

$ menuscript
menuscript[2]: syntax error at line 89 : `"' unmatched
$

Here is the code (Any help is greatly appreciated)
(Line numbers included)

1 #!/bin/ksh
2 while :
3 do
4 clear
5 cat <<++
6
7 **** MAIN MENU ****
8
9 1) Delete a file
10 2) Rename a file
11 3) Find a file
12 4) Display contents of a file using cat
13 5) Edit a file using vi
14 6) List the contents of a directory
15 7) Print todays date & time
16 8) Show users currently logged in
17 x) Exit
18 ++
19
20 echo "Please enter your selection $LOGNAME \c'
21 read selection
22 case $selection in
23 1)
24 echo "Enter a filename: \c"
25 read fname
26 if [ -r $fname ]
27 then
28 rm $fname
29 else
30 echo "menu: Cannot access file $fname"
31 fi
32 ;;
33 2)
34 echo "Enter a filename: \c"
35 read fname
36 echo "Enter a new filename: \c"
37 read frename
38 if [ -r $fname ]
39 then
40 cp $fname $frename
41 else
42 echo "menu: Cannot access the file $fname"
43 fi
44 ;;
45 3)
46 echo "Enter a filename: \c"
47 read fname
48 find . -name "$fname" -print
49 ;;
50 4)
51 echo "Enter a filename: \c"
52 read fname
53 if [ -r $fname ]
54 then
55 cat $fname
56 else
57 echo "menu: Cannot access the file $fname \c"
58 fi
59 ;;
60 5)
61 echo "Enter a filename: \c"
62 read fname
63 if [ -r $fname ]
64 then
65 vi $fname
66 else
67 echo "menu: Cannot access the file $fname \c"
68 6)
69 echo "Enter a directory name: \c"
70 read dname
71 if [ -r $dname ]
72 then
73 ls -l $dname
74 else
75 echo "menu: Cannot access the directory $dname"
76 fi
77 ;;
78 7)
79 date
80 ;;
81 8)
82 who
83 ;;
84 q|Q|e|E|x|X)
85 exit 0
86 ;;
87 *) echo "Invalid choice. Try again.";;
88 esac
89 echo "Press Enter to continue \c"
90 done
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Syntax error in a script...

Hi All, I have been fighting with a syntax error for the last 2 days, still haven't got the solution. Could you please help me, your help will be greatly appreciated. In my script I am getting a error in a for loop, its similar to the one as is below. for v_id in v1 v2 v3 v4 do... (8 Replies)
Discussion started by: rajus19
8 Replies

2. Shell Programming and Scripting

syntax error in script !!

./disk_space_util.sh ./disk_space_util.sh: Syntax error at line 24 : `then' is not expected. ================================= cat disk_space_util.sh #!/bin/sh # # Parameter Settings ORA_LOG, ORA_SCRIPT, DBA_EMAIL_LIST -- (Set in .profile) bdf | sed "s/%/ /g" | sed "/Filesystem/d" |... (13 Replies)
Discussion started by: uuser
13 Replies

3. UNIX for Dummies Questions & Answers

awk Shell Script error : "Syntax Error : `Split' unexpected

hi there i write one awk script file in shell programing the code is related to dd/mm/yy to month, day year format but i get an error please can anybody help me out in this problem ?????? i give my code here including error awk ` # date-month -- convert mm/dd/yy to month day,... (2 Replies)
Discussion started by: Herry
2 Replies

4. Shell Programming and Scripting

Syntax error with a script

Hi I not sure what is wrong with my script... when I try to run it I get the follow error: "remove: syntax error at line 77: `end of file' unexpected" Thanks in advance for any help. ans=y while do while : do echo "Please enter a name that you... (3 Replies)
Discussion started by: simpsonjr
3 Replies

5. Shell Programming and Scripting

Syntax error in script

Hey guys keep having problems with the below script syntax error near unpexpected token '0' exit 0 I have two directorys backups and Usr in the usr i have sub dir's wp,ss,pic which i would like to back up (copy those directorys to the backups directory) with user acknowledgement from command line.... (2 Replies)
Discussion started by: Spartukus
2 Replies

6. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

7. Shell Programming and Scripting

Syntax Error in Script

Hi All, I am new to Unix, I have written the following script in ksh and get a syntax error :wall:. I need some help to figure out the error and reason. The script below uses some variables from an environment file, also it executes a sql file. The sql file is correct and has no problems. I... (1 Reply)
Discussion started by: disshort23
1 Replies

8. UNIX for Dummies Questions & Answers

Syntax Error Script

Hi guys i'd like to show you this code of my script, where i couldn't find this error " #! /bin/bash #copiabin.sh: copia todos los archivos ejecutables a bin if then mkdir $HOME/bin fi # copia de archivos y contador N N=0 for ARCH in * do if # Si el archivo es... (9 Replies)
Discussion started by: Newer
9 Replies

9. Shell Programming and Scripting

First Script Syntax Error

So, I'm writing my first shell script to try to speed up the process of creating lyric files for mocp and I don't know what the error is, but considering how short the code is, I'm betting it's something super-obvious. line 7: syntax error near unexpected token `echo' line 7: ` echo... (4 Replies)
Discussion started by: D351
4 Replies

10. UNIX for Beginners Questions & Answers

Syntax error on script

Evening All (or morning for some), Could anyone have a look at the below and advise where i've going wrong with the syntax as i keep getting the below error while trying to run. Any help would be really apprecaited. ./testout: line 13: syntax error near unexpected token `else' ... (4 Replies)
Discussion started by: mutley2202
4 Replies
catch(n)						       Tcl Built-In Commands							  catch(n)

__________________________________________________________________________________________________________________________________________________

NAME
catch - Evaluate script and trap exceptional returns SYNOPSIS
catch script ?varName? _________________________________________________________________ DESCRIPTION
The catch command may be used to prevent errors from aborting command interpretation. Catch calls the Tcl interpreter recursively to exe- cute script, and always returns without raising an error, regardless of any errors that might occur while executing script. If script raises an error, catch will return a non-zero integer value corresponding to one of the exceptional return codes (see tcl.h for the definitions of code values). If the varName argument is given, then the variable it names is set to the error message from interpret- ing script. If script does not raise an error, catch will return 0 (TCL_OK) and set the variable to the value returned from script. Note that catch catches all exceptions, including those generated by break and continue as well as errors. The only errors that are not caught are syntax errors found when the script is compiled. This is because the catch command only catches errors during runtime. When the catch statement is compiled, the script is compiled as well and any syntax errors will generate a Tcl error. EXAMPLES
The catch command may be used in an if to branch based on the success of a script. if { [catch {open $someFile w} fid] } { puts stderr "Could not open $someFile for writing $fid" exit 1 } The catch command will not catch compiled syntax errors. The first time proc foo is called, the body will be compiled and a Tcl error will be generated. proc foo {} { catch {expr {1 +- }} } SEE ALSO
error(n), break(n), continue(n) KEYWORDS
catch, error Tcl 8.0 catch(n)
All times are GMT -4. The time now is 02:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy