LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-23-2008, 01:02 PM   #1
santana
Member
 
Registered: Sep 2004
Distribution: FC, ubuntu, OpenSuse
Posts: 112

Rep: Reputation: 16
bash, syntax error


Hi all, I am not a bash expert, & hope this is a trivial issue.

I have a script to automate some software tests, here is the portion that is giving me fits at the moment:
Code:
HYB_CVG_FILE=tX_HYB.cvg
TVD_CVG_FILE=tX_TVD.cvg
NPTS=`seq 200 100 600`
MATCOMMAND=path\(path,\'../matlab\'\)\;torrilhonConvergence\(\'$HYB_CVG_FILE\',\'$TVD_CVG_FILE\',\[$NPTS\]\)\;
matlab -nodesktop -r $MATCOMMAND
echo $MATCOMMAND
when run bash says:
Code:
eval: 1: Syntax error: ")" unexpected
The echo shows
Code:
path(path,'../matlab');torrilhonConvergence('tX_HYB.cvg','tX_TVD.cvg',[200 300 400 500 600]);
which is what I need matlab to see...

The problem is related to my use of []. When I remove
Code:
,\[$NPTS\]
I have no issues.

How can I get this to work??

Any advise is appreciated.
 
Old 01-23-2008, 02:00 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
I would use quotes instead of escapes to build the matlab command. Anyway, I think the problem resides in the value of the NPTS variable, which is a string representing a sequence of numbers with a newline character at the end. I guess it is the newline character that triggers the Matlab (not bash) error. I would try something like this, instead:
Code:
#!/bin/bash
HYB_CVG_FILE=tX_HYB.cvg
TVD_CVG_FILE=tX_TVD.cvg
NPTS=$(seq 200 100 600)
NPTS=$(echo $NPTS | tr -d "\n")   # this strips the trailing newline
MATCOMMAND="path(path,'../matlab');torrilhonConvergence('$HYB_CVG_FILE','$TVD_CVG_FILE',[$NPTS]);"
matlab -nodesktop -nosplash -r "$MATCOMMAND"
 
Old 01-23-2008, 02:39 PM   #3
santana
Member
 
Registered: Sep 2004
Distribution: FC, ubuntu, OpenSuse
Posts: 112

Original Poster
Rep: Reputation: 16
ttttthanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script syntax error snowman81 Programming 5 11-16-2007 03:35 AM
syntax error near unexpected token in bash using perl kambrish Programming 21 07-03-2007 01:42 PM
bash-3.1 bug or syntax error? moszern Linux - Software 1 06-12-2006 01:57 PM
BASH : syntax error semaja2 Programming 6 01-26-2006 01:33 AM
Bash For Loops gives syntax error meadensi Linux - Newbie 2 02-23-2005 11:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration