Linux Standard_in 1 Syntax Error
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
(standard_in) 1 Syntax Error Bc
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation (standard_in) 2 syntax error bc Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just standard_in 1 illegal character like you, helping each other. Join them; it only takes a minute: Sign up (standard_in) 1: syntax error in bash script up vote 0 down vote favorite I'm trying to generate some quasi random numbers to feed
Bash Standard In Syntax Error
into a monte carlo simulation. I'm using bash. I seem to have hit a syntax error which I've narrowed down to being in this bit of code. randno4=($RANDOM % 100001) upper_limit4=$(echo "scale=10; 1*75.3689"|bc) lower_limit4=$(echo "scale=10; 1*75.1689"|bc) range4=$(echo "scale=10; $upper_limit4-$lower_limit4"|bc) t_twall=`echo "scale=10; ${lower_limit4}+${range4}*${randno3}/100001" |bc` echo "$t_twall" Does anyone know why I the below output and not a value between 75.3689 and 75.1689 as that is what I would be expecting? (standard_in) 1: syntax error bash syntax-error
Bc Syntax Error
share|improve this question edited Nov 25 '14 at 19:26 asked Nov 25 '14 at 19:24 Reluctant_Linux_User 192111 1 randno4=($RANDOM % 100001) is not arithmetic evaluation. That will create a randno4='([0]="25649" [1]="%" [2]="100001")' array. Perhaps you meant randno4='$(($RANDOM % 100001))'? –Etan Reisner Nov 25 '14 at 19:27 1 That first line is fine. It just doesn't do what you think it does. Run that line and then run declare -p randno4. Then try echo "$randno4" vs. echo "${randno4[1]}". –Etan Reisner Nov 25 '14 at 19:28 3 I believe the actual error here is from bc because of the randno3 typo. –Etan Reisner Nov 25 '14 at 19:29 1 The bash man page explains the range of RANDOM. It is documented as "a random integer between 0 and 32767". –Etan Reisner Nov 26 '14 at 0:28 1 The man command should be pretty much the first Linux command you learn. Here's the bash man page –tripleee Nov 26 '14 at 6:42 | show 9 more comments 1 Answer 1 active oldest votes up vote 3 down vote accepted The first line should looks like : randno4=$((RANDOM % 100001)) (( )) is bash arithmetic, with the leading $ , the value is substituted : $(( )) When you wrote randno4=( ) you try to feed an ARRAY with a arithmetic e
here for a quick overview of the site Help Center Detailed answers to any questions you bc command in linux might have Meta Discuss the workings and policies of this site
Bash Bc
About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or bc scale posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of http://stackoverflow.com/questions/27134988/standard-in-1-syntax-error-in-bash-script 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up bc (standard_in) 1: syntax error up vote 1 down vote favorite I am trying to find the location of myfunc in the executable of: #include
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 http://unix.stackexchange.com/questions/45781/shell-script-fails-syntax-error-unexpected about Stack Overflow the company Business Learn more about hiring developers or posting ads http://www.linuxquestions.org/questions/programming-9/standard_in-1-parse-error-438431/ 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 syntax error 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 1 syntax error 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 372k696761127 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; correctly use bash instead of dash so that should not be an issue as I understand it. I can still move the shebang of course, but that does
HCL Search Reviews Search ISOs Go to Page... LinuxQuestions.org > Forums > Non-*NIX Forums > Programming (standard_in) 1: parse error 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 04-24-2006, 03:03 PM #1 timmay9162 LQ Newbie Registered: Feb 2006 Posts: 20 Rep: (standard_in) 1: parse error Code: input=input.file echo -e "Centigrade Temperature\tFahrenheit Temparature" echo -e "----------------------\t----------------------" for temp in $input do C=`cat $input |