Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 06-02-2010, 09:42 AM   #1
LQ Newbie
Registered: Jan 2010
Posts: 20

Rep: Reputation: 0
Bash Scripting Error: EOF encountered in a comment?

Here is my code and output:
o=$(echo "scale=4;${s[17]}/${s[18]}*100."|bc -l)
printf "You have used %4g%% of your allocated space." $o
EOF encountered in a comment.
(standard_in) 1: syntax error
You have used    0% of your allocated space.
The script is working correctly with the exception of the error message.
Old 06-02-2010, 09:52 AM   #2
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
The error is there, because the values s[17] and s[18] are empty. Then bc reads your command as "scale=4;/*100.", which produces the error. Check if 17 and 18 are correct.
1 members found this post helpful.
Old 06-02-2010, 09:56 AM   #3
LQ Newbie
Registered: Mar 2010
Location: On the web
Posts: 6

Rep: Reputation: 0
You could try using ${s:17:1} and ${s:18:1} instead of ${s[17]} and ${s[18]}. To my knowledge, bash doesn't support accessing string chars by array indices.
Old 06-02-2010, 10:20 AM   #4
LQ Newbie
Registered: Jan 2010
Posts: 20

Original Poster
Rep: Reputation: 0
Next question

Thanks Irmin, your answer makes sense as I wasnt receiving that error when I ran that script where quota's had been emplaced.

The next question is: how do I implement this script so that it runs whenever a terminal session has been started?

Do I add a file to /etc/profile.d?
Old 06-02-2010, 11:55 AM   #5
LQ Newbie
Registered: Jan 2010
Posts: 20

Original Poster
Rep: Reputation: 0


thanks guys


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash Scripting: Echo to Standard Error colonel_t Linux - Newbie 6 03-03-2014 08:58 AM
Bash scripting using EOF to exec external programs PB0711 Programming 6 11-04-2009 01:16 PM
BASH scripting I/O redirection error blinux1 Programming 13 03-18-2008 08:21 PM
BASH scripting error Darklight451 Linux - General 4 11-22-2004 03:59 PM
bash scripting - suppress error messages? brian0918 Programming 2 06-19-2003 11:16 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:23 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration