Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-09-2010, 12:16 AM
|
#1
|
|
LQ Newbie
Registered: Jul 2010
Posts: 3
Rep:
|
bash: syntax error near unexpected token `('
Hi all,
I am new to this forum. I am sorry if this is not correct place to post this.
I was trying to run small shell script, but could not run. I got the error like in subject. Can any one help me to figure this problem.
This is exact way i was trying to do.
[mycom7] # ./ctopo.sh um_test1 [(1,2),(2,1)]
bash: syntax error near unexpected token `('
ctopo.sh script takes two strings as input, here first one is um_test1 and second one is [(1,2),(2,1)]. Then it passes to the python script it takes two strings.
#!/bin/bash
slice=$1
links=$2
exec `/usr/bin/plcsh /root/gra2.py $slice $links`
Thank you
--Ram
|
|
|
|
07-09-2010, 12:29 AM
|
#2
|
|
Member
Registered: Jun 2010
Posts: 361
Rep:
|
Paratheses are, amongst others, shell meta-characters with special meaning to the shell. If you want to pass them as-is to a script or executable, you have to tell the shell to ignore them when evaluating your command by escaping or quoting them. In your case, the best way is to double-quote the whole second parameter.
|
|
|
|
07-09-2010, 04:25 PM
|
#3
|
|
Member
Registered: Oct 2003
Location: Chico, CA, USA
Distribution: Linux Mint
Posts: 704
Rep:
|
Might it also work to quote the variables in the shell script, like this?
Code:
exec `/usr/bin/plcsh /root/gra2.py "$slice" "$links"`
--Dane
|
|
|
|
07-09-2010, 04:41 PM
|
#4
|
|
Member
Registered: Jun 2010
Posts: 361
Rep:
|
No. The shell interprets the command you are typing, ( and ) are characters with a special meaning for the shell, so you MUST hide them by quoting or by escaping.
|
|
|
|
07-10-2010, 01:37 AM
|
#5
|
|
Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 6,314
|
Another piece of advice when writing a script is to test and ask yourself, how would this work on the command line?
So to take your script, ask yourself if the following would work:
Code:
/usr/bin/plcsh /root/gra2.py um_test1 [(1,2),(2,1)]
Then test it on the command line to confirm.
|
|
|
|
07-10-2010, 11:37 PM
|
#6
|
|
LQ Newbie
Registered: Jul 2010
Posts: 3
Original Poster
Rep:
|
Thank you very much for all your replies. Currently i can not reach my server(remote one, on which i am trying to integrate my application ) to test these solutions, i guess there is a network issue.
I will get back to you soon.
Hi Grail. Thank you for your advice. I will definitely mark it as solved, if these solutions work.
|
|
|
|
07-13-2010, 08:54 PM
|
#7
|
|
LQ Newbie
Registered: Jul 2010
Posts: 3
Original Poster
Rep:
|
Thank you all. It is solved with double quote the second parameter like..
[mycom7] # ./ctopo.sh um_test1 "[(1,2),(2,1)]"
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:39 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|