LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-16-2015, 04:51 AM   #16
like100ninjas
LQ Newbie
 
Registered: Apr 2015
Posts: 24

Original Poster
Rep: Reputation: Disabled

stop with the cussing and the getting angry. just go bother another thread. did you have questions here, or are you just here to troll? just go away.

edit: you can't make the script work. you're pasting from manpages with no idea what the actual problem is. you came here in the first place to start a flamewar and troll. just GO. AWAY. you're not answering my question or helping me understand anything. your only intention is to try and belittle me while offering nothing constructive. just don't reply again. find something else to occupy your time.

Last edited by like100ninjas; 12-16-2015 at 04:57 AM. Reason: had to underline the go away part
 
Old 12-16-2015, 03:23 PM   #17
fu9ar
Member
 
Registered: Oct 2014
Location: Cyberinternetspace
Distribution: Slackware, mostly
Posts: 49

Rep: Reputation: 2
Calm down, sparky. First off, those aren't manpages. Those lines of output are from help read, which are not man pages. man pages are man pages.

Secondly: What? You came to the internet and expected someone to just fix a poorly written, uncommented, broken desktop rice script for you?

Finally: I'm teaching you something critical to the practice of programming, if you would pull your head from your behind long enough to learn it.
 
Old 12-17-2015, 05:35 PM   #18
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 812

Rep: Reputation: 216Reputation: 216Reputation: 216
Let's get back to topic.

In your while condition you are doing this:
Code:
$( read -r line )
Now, look at the following tests:
Code:
$ read -r line
bla bla
$ echo $line
bla bla
$ foobar=$( read -r line_2 )
bla blubb
$ echo $foobar

$ echo $line_2

$
So, as you correctly suggested, the read command happens in a subshell, and the assigned value of the line variable will never become available in your script.
On top of that, the read command does not write anything to stdout, so the $() returns an empty string. Hence, the length of the string (-n test) will never be non-zero, and your condition will never be true.

What you need to do is e.g. this:

Code:
read -r line
while [[ -n $line ]] {
    echo "You typed: "$line
    # do stuff
    read -r line

}
(I am sure it can be done in a more elegant way, but you get the point)
 
Old 12-18-2015, 10:17 AM   #19
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 3,110

Rep: Reputation: 543Reputation: 543Reputation: 543Reputation: 543Reputation: 543Reputation: 543
Quote:
Originally Posted by like100ninjas View Post
edit: once again, trying to make this lemonbar script work. i fixed all the error messages, and the script runs. i think my problem might be that i'm testing `read -r line' in a subshell, so the script never really parses the lines i'm trying to read. just a hunch. anyone know how to fix this? or maybe something else is wrong.

edit again: i keep trying different things but no text shows up on the bar still. i've tried adding "print $line" underneath the while line and nothing shows up.

$HOME/etc/lemonbar/panel_bar
Code:
#!/usr/bin/zsh
off of another place on netland -> and lemonBar -> example
Code:
#!/usr/bin/bash

# Define the clock
Clock() {
        DATE=$(date "+a b %d, %T")

        echo -n "$DATE"
}

# Print the clock

while true; do
        echo "%{c}%{Fyellow}%{Bblue} $(Clock)%{F-}"
        sleep 1;
done
Pont is: it is using BASH too

I use i3Status (bar) myself

though that seems rather simple, have you tried typing it all out right, if it is the error that states it is near } -- usally means you might have something within that file that is tossing an error, as I seen no missing quote marks in the code.

you could try a fresh sheet of Epaper and write it out again or just saveAs over top of it, the same file, as well. to clean it up and seee if it might have been something within the file itself.

ot try a different info bar -- or just format and install fresh OS (just playing)

zsh, don't know but most likely it is a typo error missing something one of them really stupid formatting errors like a quote or a space missing or is there that is not suppose to be

Last edited by BW-userx; 12-18-2015 at 10:29 AM.
 
  


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
LXer: Shell Scripting Part 3: Decision Control Structures in Shell Scripts LXer Syndicated Linux News 0 05-05-2015 11:01 PM
LXer: Shell Scripting Part 2: Accepting Inputs and Performing Shell Arithmetic LXer Syndicated Linux News 0 04-30-2015 08:10 AM
LXer: Shell Scripting Part I: Getting started with bash scripting LXer Syndicated Linux News 0 04-29-2015 09:03 AM
win32,shell code,shell programming,shell scripting? mr.cracker Linux - Newbie 4 07-13-2013 12:20 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 05:29 AM


All times are GMT -5. The time now is 04:52 AM.

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