syntax error at line 28: `(' unexpected


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting syntax error at line 28: `(' unexpected
# 1  
Old 12-05-2008
syntax error at line 28: `(' unexpected

hi can anyone pls look into this....shell script...

Pls find the error below:

> sh -n tmp
tmp: syntax error at line 28: `(' unexpected


isql -Usa -S$1 -P`grep $1 dbpassword|cut -d ":" -f3` -w2000 -b<<!
set nocount on
declare @i int
declare @dbname char(6)
declare @tmp int
if ($3="default")
set @i=3
else if ($3="log")
set @i=4
set @dbname="$2"
if (@dbname="tempdb")
begin
select @tmp=count(*) from sysusages where segmap!=7 and db_name(dbid)="$2"
if (@tmp <>(select count(*) from sysusages where db_name(dbid)="$2" and segmap=7))
begin
print "Pls use sp_extend segment to add $3 segment on the dev whose segmap!=7"
exit
end
else if(@tmp= 0)
begin
select "FREE SPACE: ",sum(curunreservedpgs(dbid,lstart,unreservedpgs)*(@@maxpagesize/(1024*1024))),
"Total Space: ",sum(size)/((1024*1024)/@@maxpagesize),"Server Name : ",@@servername from sysusages
where db_name(dbid)="$2" and segmap=7
end
end
go
!
select "FREE SPACE: ",sum(curunreservedpgs(dbid,lstart,unreservedpgs)*(@@maxpagesize/(1024*1024))),
"Total Space: ",sum(size)/((1024*1024)/@@maxpagesize),"Server Name : ",@@servername from sysusages
where db_name(dbid)="$2" and segmap=@i or segmap=7
go
select spid,cmd,physical_io,status from master..sysprocesses where cmd not like "AWA%"
go
!
isql -Usa -SCHI_DRUM_MONITOR -Ddba_database -Psy91base -w2000<<!
select top 20 yyyymmdd,allocated_to_db,unused_in_db,used_in_db from space_usage_history where
instname="$1" and db="$2" order by yyyymmdd desc
go
!
# 2  
Old 12-05-2008
keep all the SQL statements before 27th line
# 3  
Old 12-05-2008
The problem is on the 28th line:
Code:
select "FREE SPACE: ",sum(curunreservedpgs(dbid,lstart,unreservedpgs)*(@@maxpagesize/(1024*1024))),
"Total Space: ",sum(size)/((1024*1024)/@@maxpagesize),"Server Name : ",@@servername from sysusages
where db_name(dbid)="$2" and segmap=@i or segmap=7

You should put the entire query in double-quotes, not just some parts. And put single-quotes around the $2 expression because this might be a string that needs quoting. (If Oracle needs double-quotes, then use \" instead of ').
Code:
select "FREE SPACE:,sum(curunreservedpgs(dbid,lstart,unreservedpgs)*(@@maxpagesize/(1024*1024))),Total Space: ,sum(size)/((1024*1024)/@@maxpagesize),Server Name : ,@@servername from sysusages
where db_name(dbid)='$2' and segmap=@i or segmap=7"

# 4  
Old 12-05-2008
Actually

select "anything" prints anything

1> select "FREE SPACE: ,sum(curunreservedpgs(dbid,lstart,unreservedpgs)*(@@maxpagesize/(1024*1024))),Total Space: ,sum(size)/((1024*1024)/@@maxpagesize),Server Name : ,@@servername from sysusages where db_name(dbid)='EMbsDb' and segmap=3"
2>
3> go

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FREE SPACE: ,sum(curunreservedpgs(dbid,lstart,unreservedpgs)*(@@maxpagesize/(1024*1024))),Total Space: ,sum(size)/((1024*1024)/@@maxpagesize),Server Name : ,@@servername from sysusages where db_name(dbid)='EMbsDb' and segmap=3

(1 row affected)
1>

------------------------
The statement when run in isql (sybase database) gives desired results but when included int the script -its throwing errors:
1> select "FREE SPACE: ",sum(curunreservedpgs(dbid,lstart,unreservedpgs)*(@@maxpagesize/(1024*1024))),"Total Space: ",sum(size)/((1024*1024)/@@maxpagesize),"Server Name : ",@@servername from sysusages where db_name(dbid)="EMbsDb" and segmap=3
2> go

------------ ----------- ------------- ----------- -------------- ------------------------------
FREE SPACE: 0 Total Space: 7700 Server Name : RER_PROD_125
# 5  
Old 12-05-2008
So you need to double-quote words inside your double-quoted script. Fine:

Code:
select "\"FREE SPACE:\",
sum(curunreservedpgs(dbid,lstart,unreservedpgs)*(@@maxpagesize/(1024*1024))),
\"Total Space: \",
sum(size)/((1024*1024)/@@maxpagesize),
\"Server Name :\",
@@servername from sysusages
where db_name(dbid)='$2' and segmap=@i or segmap=7"

# 6  
Old 12-05-2008
Anyways ...Thank you for quick reply i think sybase doesnt accept this esc sequence.

1> select "\"FREE SPACE:\""
2> go
Msg 102, Level 15, State 1:
Server 'RER_QA_125', Line 1:
Incorrect syntax near '\'.
1>



1> select "\"FREE SPACE:\",
2> sum(curunreservedpgs(dbid,lstart,unreservedpgs)*(@@maxpagesize/(1024*1024))),
3> \"Total Space: \",
4> sum(size)/((1024*1024)/@@maxpagesize),
5> \"Server Name :\",
6> @@servername from sysusageswhere db_name(dbid)='FiTraderDb' and segmap=3"
7> go
Msg 102, Level 15, State 1:
Server 'RER_QA_125', Line 1:
Incorrect syntax near '\'.
# 7  
Old 12-05-2008
Sybase won't see the escape sequence because BASH / KSH will!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Syntax error at line 24: `(' unexpected

Hi, I am getting an wired error.... the script is running fine when i run it manually... but the same when i try to run in nohup mode, i am getting error if Error: syntax error at line 24: `(' unexpected The above if is the 24th line!!! I dont understand the error... (4 Replies)
Discussion started by: Nithz
4 Replies

3. Shell Programming and Scripting

Syntax error at line 14: `gw_user=' unexpected

Masters, i iam writing a script (dont have much experience in the process of learning) which handles file copy to multiple servers and users for deployment purpose. Below is the snippet. When ever i run i get syntax error but it works fine on another machine. Please help me out. if then... (10 Replies)
Discussion started by: ameyrk
10 Replies

4. 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

5. UNIX for Dummies Questions & Answers

syntax error at line 8: `(' unexpected

Hi I am having a shell script load_data.sh which calls /home/users/project/.profile. When am executing the script, am getting below error: $sh -x bin/load_data.sh null + . /home/users/project/.profile bin/load_data.sh: syntax error at line 8: `(' unexpected The line which is throwing... (1 Reply)
Discussion started by: brijesh.dixit
1 Replies

6. 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

7. Shell Programming and Scripting

interface_file_ff.sh[99]: syntax error at line 1 : `)' unexpected

Hi, I tried to execute the following code but it showed the output mobile number : 35353425 corr plan id : 13-may-2008 corr target : 551 active_dt : 23414 no ident : IDD action name: A To get the subscriber number for the given mobile number and check if it is active and not... (1 Reply)
Discussion started by: geekforu
1 Replies

8. 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

9. UNIX for Dummies Questions & Answers

syntax error at line 33: `elif` unexpected

#!/bin/sh echo "Choose option: e, d, l, t, p, or x." read option if test $option = e then echo "Filename?" read file if test ! -f $file then echo "No such file" else echo "Yes its a file" fi ... (4 Replies)
Discussion started by: hazy
4 Replies

10. Programming

sh: syntax error at line 1: `>' unexpected

I compiled C program under SUN OS sparcv9 ...I had a problem related to SIGBUS which has been resolved by adding an option to the CC compiler which is memory alignement option ..-memalign=1i as I remmber ...after running the program I got the below error please let me KNow more details what should... (2 Replies)
Discussion started by: atiato
2 Replies
Login or Register to Ask a Question