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


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

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


Here is my code and output:
Code:
#!/bin/bash
s=($(quota))
o=$(echo "scale=4;${s[17]}/${s[18]}*100."|bc -l)
printf "You have used %4g%% of your allocated space." $o
Code:
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
irmin
Member
 
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
LinuxTutBlog
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
dilzniksan
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 gnome-terminal.sh file to /etc/profile.d?
 
Old 06-02-2010, 11:55 AM   #5
dilzniksan
LQ Newbie
 
Registered: Jan 2010
Posts: 20

Original Poster
Rep: Reputation: 0
solved

~/.bashrc

thanks guys
 
  


Reply


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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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