Perl 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 the workings and policies of this
Syntax Error: Redirection Unexpected Ubuntu
site About Us Learn more about Stack Overflow the company Business Learn more cron redirection unexpected about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x !#/bin/bash: not found Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up sh: 1:
Bash Redirection
Syntax error: redirection unexpected when using backticks perl up vote 2 down vote favorite my $mysql_cmd = 'debconf-set-selections <<< \'mysql-server mysql-server/root_password password 6ygr\' ;debconf-set-selections <<< \'mysql-server mysql-server/root_password_again password 6ygr\'; '.our $install_cmd." mysql-server"; my $mysql_stat = `$mysql_cmd`; I'm using the above piece of code to install mysql from my perl script. But I'm getting this error sh: 1: Syntax error: redirection unexpected When I printed
Debconf-set-selections
$mysql_cmd I got debconf-set-selections <<< 'mysql-server mysql-server/root_password password 6ygr' ;debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password 6ygr'; apt-get -y install mysql-server which seems to correct and manually executing this command in shell gives desired output. But when execute the perl script it gives error. Any idea? bash perl backticks share|improve this question asked Mar 20 '15 at 12:47 Harikrishnan 4,35244394 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote accepted You should use IPC::Run for this kind of jobs use IPC::Run qw(run); my @options = map "mysql-server mysql-server/$_ password 6ygr", qw(root_password root_password_again); my $mysql_stat; run [qw(debconf-set-selections)], '<', \$_, '>>', \$mysql_stat, '2>>', \$mysql_stat or die "debconf-set-selections: $?" for @options; run [ $install_cmd, 'mysql-server' ], '>>', \$mysql_stat, '2>>', \$mysql_stat or die "$install_cmd: $?"; The main reason is you don't like to deal with quoting issues and incompatibilities and so on. share|improve this answer edited Mar 20 '15 at 14:05 answered Mar 20 '15 at 13:45 Hynek -Pichi- Vychodil 19.7k33161 That's a ridiculously inelegant solution to a simple problem. Ouch. –tpartee Jun 5 '15 at 20:56 @tpartee: I would expect someone with your experience will appreci
Search Tutorials/Articles Search HCL Search Reviews Search ISOs Go to Page... LinuxQuestions.org > Forums > Linux Forums > Linux - General bash script: Syntax error: redirection unexpected syntax error: "(" unexpected User Name Remember Me? Password Linux - General This Linux forum is
Bash Split String
for general Linux questions and discussion. If it is Linux Related and doesn't seem to fit in any other forum then this is the place. 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 http://stackoverflow.com/questions/29166876/sh-1-syntax-error-redirection-unexpected-when-using-backticks-perl 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 http://www.linuxquestions.org/questions/linux-general-1/bash-script-syntax-error-redirection-unexpected-927865/ | 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 02-06-2012, 04:50 AM #1 make Member Registered: Apr 2004 Distribution: Mandriva, Ubuntu, openSuSE, FreeBSD, Op
Sign in Pricing Blog Support Search GitHub This repository Watch 733 Star 11,191 Fork 1,991 coreos/etcd Code Issues 87 https://github.com/coreos/etcd/issues/3417 Pull requests 46 Projects 0 Pulse Graphs New issue Build script http://unix.stackexchange.com/questions/45781/shell-script-fails-syntax-error-unexpected exit with error "Syntax error: redirection unexpected" #3417 Closed fatih opened this Issue Sep 1, 2015 · 4 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 3 participants fatih commented Sep 1, 2015 Hi, We syntax error use etcd for our project Kite (https://github.com/koding/kite). We saw that our latest PR all failed because we couldn't start up ETCD on travis. Here is on of the failed builds: https://travis-ci.org/koding/kite/jobs/78066380 Investigating more it seems the build script doesn't execute well because the <<< herestring are not supported on sh. I think this was introduced two perl syntax error days ago with: dd4317d More info about this can be also find in this SO question: http://stackoverflow.com/questions/2462317/bash-syntax-error-redirection-unexpected I assume changing the script reference to /bin/bash would solve this problem. Another solution would be not using <<< at all. fatih referenced this issue in koding/kite Sep 1, 2015 Merged kontrol: expose handlers to let users customize methods #126 AdoHe commented Sep 1, 2015 @fatih I think both options will solve this problem, maybe the second one is much better. I just create a new pull request, you may have a look: #3418 AdoHe added a commit that referenced this issue Sep 1, 2015 AdoHe #3417 4d12a14 yichengq commente
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 with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux 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 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 Shell script fails: Syntax error: “(” unexpected up vote 31 down vote favorite 7 I've been working on a script that automates setting up a development environment for Raspberry Pi development (step by step details that work are here). The script is linked in that article but convenience you can find it here also. Now when run this script install and sets up the environment without error but you have to enter your sudo password more than once due to sudo's time-out value by default. So I started experimenting by removing all the sudo lines and running the whole script via sudo at the command line like so: kemra102@ubuntuvm:~$ sudo ./pi_dev_env_install.sh This works fine as expected and gets most of the way through until this point: ./pi_dev_env_install: 68: ./pi_dev_env_install.sh: Syntax error: "(" unexpected Now this line worked fine previously when not running the whole script with sudo. There is nothing about this line running as sudo that should stop it working to my knowledge, does anyone have any ideas? bash shell ubuntu shell-script share|improve this question edited Aug 18 '12 at 12:08 Gilles 373k696801129 asked Aug 18 '12 at 11:37 kemra102 4731613 The shebang is really in line 9? Due to Ubuntu's DashAsBinSh affinity I suspect your script is interpreted by dash instead of bash. Try to move the shebang in line 1. –manatwork Aug 18 '12 at 11:45 According to that article calling /bin/bash directly instead of /bin/sh will; corre