Dependencies.sh 6 Syntax Error Redirection Unexpected
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss cron redirection unexpected the workings and policies of this site About Us Learn more
Bash Syntax Error Near Unexpected Token
about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow bash redirection 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 you, helping each
Debconf-set-selections
other. Join them; it only takes a minute: Sign up Bash: Syntax error: redirection unexpected up vote 53 down vote favorite 11 I do this in a script: read direc <<< $(basename `pwd`) and I get: Syntax error: redirection unexpected in an ubuntu machine /bin/bash --version GNU bash, version 4.0.33(1)-release (x86_64-pc-linux-gnu) while I do not get this error syntax error: "(" unexpected in another suse machine: /bin/bash --version GNU bash, version 3.2.39(1)-release (x86_64-suse-linux-gnu) Copyright (C) 2007 Free Software Foundation, Inc. Why the error? bash share|improve this question edited Mar 6 at 17:20 Willi Mentzel 2,33691840 asked Mar 17 '10 at 12:58 flow 4,2793295157 For reference, the command works on cygwin as well ( /bin/bash --version GNU bash, version 3.2.49(23)-release (i686-pc-cygwin) Copyright (C) 2007 Free Software Foundation, Inc. ) –hlovdal Mar 17 '10 at 13:08 add a comment| 3 Answers 3 active oldest votes up vote 93 down vote accepted Does your script reference /bin/bash or /bin/sh in its hash bang line? The default system shell in Ubuntu is dash, not bash, so if you have #!/bin/sh then your script will be using a different shell than you expect. Dash does not have the <<< redirection operator. share|improve this answer answered Mar 17 '10 at 13:05 John Kugelman 173k36306384 Is there a way to fix this easily ? –Sliq Dec 21 '14 at 20:52 3 @Sliq, yes use !#/bin/bash. &nda
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
Bin Bash
with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack
Bash Array
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 for loop bash up shell script syntax error: redirection unexpected during done command up vote 0 down vote favorite So, I'm trying to make a shell script for a class and it basically just performs a few administrative operations. Right now, I'm getting a http://stackoverflow.com/questions/2462317/bash-syntax-error-redirection-unexpected syntax error on the done command on lines 27 and 45. I feel it might be my use of awk. #!/bin/sh ps -cefl > userInfo while [ "$menuOption" != 4 ]; do echo "====================================" echo "Select a menu option!" echo "(1) Ancestry History" echo "(2) Who's online" echo "(3) What process a user is running" echo "(4) Exit" echo -n "Menu option:" read menuOption echo " " if [ "$menuOption" -eq 1 ]; then echo "The ancestry tree for the current process is. http://stackoverflow.com/questions/18777815/shell-script-syntax-error-redirection-unexpected-during-done-command . ." echo " " PID=$$ while [ $PID -ne 1 ] do echo $PID echo " | " while read PIDS; do myPID=$(echo $PIDS | awk '{print $1}') myPPID=$(echo $PIDS | awk '{print $2}') if [ $myPID -eq $PID ]; then PID=$myPPID fi done < <(grep $PID userInfo | awk '{printf "%i %i\n",$4,$5}') done echo " 1 " echo " " elif [ "$menuOption" -eq 2 ]; then echo "Online users:" echo "-------------" who | awk '{print $1}' | sort -u echo "-------" echo " " elif [ "$menuOption" -eq 3 ]; then i=0 echo "Select a user to see the processes!" echo "-----------------------------------" while read value; do listNames["$i"]="$value" echo "$i)${listNames[$i]}" i=$(($i+1)) done < <(who | awk '{print $1}' | sort -u) echo -n "Select user: " read userOption echo " " echo "You've selected: ${listNames[$userOption]}" grep ${listNames[$userOption]} userInfo | awk '{printf "%-7s %-7s %-7s %-7s %-7s %-7s %-10s %s %s\n",$3,$4,$5,$9,$11,$12,$13,$14,$15}' | sort; echo " " elif [ "$menuOption" -eq 4 ]; then echo "Exiting Script!" fi done bash shell ubuntu awk share|improve this question asked Sep 13 '13 at 3:27 T.J. Williams 114 You might want to read about the select command in bash. –chepner Sep 13 '13 at 13:12 add a comment| 2 Answers 2 active oldest votes up vote 6 down vote No, it's due to your use of sh as an interpreter. Change it to bash. share|improve this answer answered Sep 13 '13 at 3:29 Ignacio Vazquez-Abrams 444k63794953 perfec
>Revision 6.505 Apr 2012Revised by: mc'TUNGSTENBERRY' releaseRevision 6.627 Nov 2012Revised by: mc'YTTERBIUMBERRY' releaseRevision 1010 Mar 2014Revised by: mc'PUBLICDOMAIN' releasehttp://www.tldp.org/LDP/abs/html/abs-guide.html >