Bin/sh Syntax Error Unexpected
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn bin sh c line 1 syntax error unexpected end of file more about hiring developers or posting ads with us Unix & Linux Questions Tags Users Badges
Bin Sh C Line 0 Syntax Error Near Unexpected Token
Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like bin sh 1 syntax error unterminated quoted string operating systems. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top `Syntax error: “(” unexpected` when
Syntax Error Unexpected Expecting Syntaxerror
creating an array up vote 1 down vote favorite 1 I have two (Debian) Linux servers. I am creating a shell script. On the first one I create an array thus: #!/bin/bash target_array=( "/home/user/direct/filename -p123 -r" ) That works fine. But when I run this on the other server I get: Syntax error: "(" unexpected As far as I can tell both servers are the same. Can anyone shed some light on why this doesn't work? If I syntax error ( unexpected bash array type it into the terminal directly it is fine?? It would appear that when I run it as sh scriptname.sh I get the error, but if I run it as ./scriptname.sh it seems to be ok. What's the difference? bash shell-script array share|improve this question edited Jan 7 at 23:36 Gilles 369k666681119 asked Jan 7 at 14:42 IGGt 398213 Did you copy-pasted the script between the two server? try cat -v script to see if there are spurious char. –LilloX Jan 7 at 14:50 2 sh is not bash and so running it as sh scriptname.sh is wrong –Eric Renouf Jan 7 at 15:01 add a comment| 3 Answers 3 active oldest votes up vote 6 down vote accepted When you use ./scriptname.sh it executes with /bin/bash as in the first line with #!. But when you use sh scriptname.sh it executes sh, not bash. The sh shell has no syntax to create arrays, but Bash has the syntax you used. share|improve this answer edited Jan 7 at 23:37 Gilles 369k666681119 answered Jan 7 at 15:06 Konstantin Morenko 1986 OK, that makes sense now. As you can probably tell I'm quite new to Linux (currently trying to convert my Powershell scripts shell/bash scripts). I will stick to using ./ from now on. cheers –IGGt Jan 7 at 15:24 That's not necessarily, but there must be coordinatio
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta
Syntax Error At Line Unexpected
Discuss the workings and policies of this site About Us Learn
Syntax Error ( Unexpected Ubuntu
more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us ksh syntax error unexpected Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like http://unix.stackexchange.com/questions/253892/syntax-error-unexpected-when-creating-an-array you, helping each other. Join them; it only takes a minute: Sign up how to fix /bin/sh: syntax error: unexpected “(” without changing to /bin/bash up vote 0 down vote favorite I have this makefile: SHELL = /bin/sh INSTALL =/usr/bin/install INSTALL_PROGRAM = $(INSTALL) INSTALL_DATA = $(INSTALL) -m 644 STRIP=$(TARGET_CROSS)strip EXEC=monApp SRC= $(wildcard src/*.cpp) OBJ= $(SRC:.cpp=.o) CXX=$(TARGET_CROSS)g++ CXXFLAGS http://stackoverflow.com/questions/17944710/how-to-fix-bin-sh-syntax-error-unexpected-without-changing-to-bin-bash = -I./include –I$(STAGING_DIR)/include –I(STAGING_DIR)/usr/include/ LDFLAGS = -g -Wall -L$(STAGING_DIR)/lib –lEGL –lGLESv2 –lIMGegl –L$(STAGING_DIR)/usr/lib all: $(EXEC) $(EXEC): $(OBJ) $(CXX) -o $@ $^ $(LDFLAGS) %.o: %.cpp @$(CXX) -o $@ -c $< $(CXXFLAGS) .PHONY: clean clean: @rm -rf src/*.o @rm -rf $(EXEC) install: $(EXEC) mkdir -p ./package.release $(INSTALL_PROGRAM) $(EXEC) ./package.release/ $(STRIP) ./package.release/$(EXEC) uninstall: @rm -rf ./package.release/ How do I fix this issue without changing to /bin/bash (i do not have bash so i have to use sh)? Thank you, bash shell makefile share|improve this question edited Jul 30 '13 at 10:39 Barmar 270k23124211 asked Jul 30 '13 at 10:37 Crazywiz Wiz 2314 4 Which line is the errr on? –Barmar Jul 30 '13 at 10:38 1 I don't see any parentheses in any of the shell commands. Those are all makefile variables that get substituted before running the shell. –Barmar Jul 30 '13 at 10:44 10 add missing $ to (STAGING_DIR) in the CXXFLAGS –J.F. Sebastian Jul 30 '13 at 10:44 Thank you Sebastian, after i googled
Tags Search LQ Wiki Search Tutorials/Articles Search HCL Search Reviews Search ISOs Go to Page... LinuxQuestions.org > Forums > Non-*NIX Forums > Programming http://www.linuxquestions.org/questions/programming-9/bin-sh-syntax-error-unexpected-906697/ [SOLVED] /bin/sh: Syntax error: "(" unexpected User Name Remember Me? Password Programming This forum is for all programming questions. The question does not have to be directly related to Linux http://cygwin.com/ml/cygwin/2005-08/msg00773.html 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 syntax error 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 syntax error unexpected 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. Introduction to Linux - A Hands on Guide This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter. For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own. Click Here to receive this Complete Guide absolutely free. Search this Thread
/bin/sh scripts causing "unexpected "("" errors From: "Dave Korn"