1 Syntax Error Unexpected Sh
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 more about hiring developers or posting ads sh syntax error unexpected end of file with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux line 1 syntax error unexpected Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute: Sign ksh syntax error unexpected 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 creating an array up vote 1 down vote favorite 1 I have two
Syntax Error At Line (' Unexpected
(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 type it into the terminal directly it is fine?? It would appear that when I run it as sh scriptname.sh syntax error ( unexpected ubuntu 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 coordination between #!/bin/sh and sh script.sh (or #!/bin/bash and bash script.sh) –Konstantin Morenko Jan 7 at 15:26 3 The sh language has no arrays (a[index]=x or a=(x y)). Some sh interpreters support arrays, only ksh88 (not ported to Li
Get Kubuntu Get Xubuntu Get Lubuntu Get UbuntuStudio Get Mythbuntu Get Edubuntu Get Ubuntu-GNOME Get UbuntuKylin Ubuntu Code of Conduct Ubuntu Wiki Community Wiki Other Support Launchpad Answers Ubuntu IRC Support AskUbuntu Official Documentation User Documentation Social syntax error at line 1 (' unexpected in shell script Media Facebook Twitter Useful Links Distrowatch Bugs: Ubuntu PPAs: Ubuntu Web Upd8: Ubuntu OMG!
Syntax Error ( Unexpected Bash Array
Ubuntu Ubuntu Insights Planet Ubuntu Activity Page Please read before SSO login Advanced Search Forum The Ubuntu Forum Community Ubuntu Specialised Support Development
Line 1: Syntax Error: Unexpected Word (expecting ")")
& Programming Programming Talk running sh-script, resulting in Syntax error: "(" unexpected Having an Issue With Posting ? Do you want to help us debug the posting issues ? < is the place to report it, http://unix.stackexchange.com/questions/253892/syntax-error-unexpected-when-creating-an-array thanks ! Page 1 of 2 12 Last Jump to page: Results 1 to 10 of 17 Thread: running sh-script, resulting in Syntax error: "(" unexpected Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode July 12th, 2007 #1 stigala View Profile View Forum Posts Private Message First Cup of Ubuntu Join Date Jul 2007 Beans 5 running sh-script, resulting in Syntax error: https://ubuntuforums.org/showthread.php?t=499045 "(" unexpected Hi, I'm trying to run a script on ubuntu 7.04; stig@stig-laptop:~/mosesdecoder$ ./regenerate-makefiles.sh ./regenerate-makefiles.sh: 13: Syntax error: "(" unexpected but then I get the syntax error. Below is the first lines in the script, line 13 in red. #!/bin/sh # NOTE: # Versions 1.9 (or higher) of aclocal and automake are required. # For Mac OSX users: # Standard distribution usually includes versions 1.6. # Get versions 1.9 or higher # Set the following variable to the correct paths #ACLOCAL="/path/to/aclocal-1.9" #AUTOMAKE="/path/to/automake-1.9" function die () { echo "$@" >&2 exit 1 } ... I already have automake (GNU automake 1.9.6) and aclocal (GNU automake 1.9.6). Setting the paths is only for Mac OSX users, so I didn't try to set any of those paths. Anyone can explain this? Thanks for any help, Stig Adv Reply July 12th, 2007 #2 Rui Pais View Profile View Forum Posts I Ubuntu, Therefore, I Am Join Date Oct 2004 Beans 2,324 Re: running sh-script, resulting in Syntax error: "(" unexpected Hi. the (inexistent) problem is the 1st line in combination with Ubuntu. When you run it using ./ it will use the shell you mention on first line, in your case: #!/bin/sh if you do a ls -l /bin/sh you will see that it's just a link to dash. Ubuntu, since Edgy, re
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 http://stackoverflow.com/questions/17944710/how-to-fix-bin-sh-syntax-error-unexpected-without-changing-to-bin-bash site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x http://www.linuxquestions.org/questions/programming-9/bin-sh-syntax-error-unexpected-906697/ Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up how to syntax error 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 = -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) syntax error unexpected %.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 the error i was sure it was because i was not using bash, can't believe i missed something so obvious... it's embarrassing actually:( –Crazywiz Wiz Jul 30 '13 at 11:00 3 This question appears to be off-topic because it is about fix
Search HCL Search Reviews Search ISOs Go to Page... LinuxQuestions.org > Forums > Non-*NIX Forums > Programming [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 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. 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 10-06-2011, 02:58 AM #1 manojrb18 LQ Newbie Registered: Oct 2011 Posts: 2 Rep: /bin/sh: Syntax error: "(" unexpected Hi, I am getting below error while building the u-boot and flashloader source. [ENV] out/spi/u-boot-env.txt [ENV] out/spi/u-boot-env.bin /bin/sh: Syntax error: "(" unexpected make: *** [out/spi/u-boot.z77.pad] Error 2 I do not understand what can be the causes of this. I have tried changing the "/bin/sh" to "/bin/bash" in some the scripts present in source tree. But still the error occurs. Will appreciate any help in resolving this. Thanks a lot in advance. Manoj manojrb18 View Public Profile View LQ Blog View Review Entries View HCL Ent