You are not logged in.
I'm having a problem piping the date to dzen2 using the date command in a while loop in bash.
In my startup script I have this line to start the panel and the script to pipe the info:
statusbar | dzen2 -h $PANEL_HEIGHT -dock -ta l -title-name panel -fn $FONT -fg $PANEL_TEXT_LIGHT -bg $PANEL_BG &and then the statusbar script looks like this:
while true ; do
echo "$(date +%I:%M %p)"
sleep 1
doneThat isn't the complete statusbar script, but i've identified the date command as the problem. For whatever reason, when the date command is in the loop, there is no output to the panel, and if I monitor my system resources I can see that my computer's memory is getting used up extremely quickly. It seems like it spawning a bunch of instances of the script. I'm not extremely experienced with linux, and definitely not with bash, so I have absolutely no clue whats going on here.
Offline
$ echo "$(date +%I:%M %p)"
date: extra operand ‘%p’
Try 'date --help' for more information.Edit: since you're basically saying you're a newbie (and this also probably fits better in the Newbie Corner), I'll add that you should put the formatting string in (single) quotes to turn it into a single argument.
Last edited by Raynman (2014-05-02 12:33:17)
Offline
The date format needs to be one parameter. Try wrapping it with '...', eg:
echo "$(date '+%I:%M %p')"Incidentally, it often helps to run a command manually, outside the full script/pipeline, to see if there are any issues.
Either that and/or redirect the error output so you can see it: http://mywiki.wooledge.org/BashGuide/InputAndOutput
Last edited by skanky (2014-05-02 12:35:28)
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
$ echo "$(date +%I:%M %p)" date: extra operand ‘%p’ Try 'date --help' for more information.Edit: since you're basically saying you're a newbie (and this also probably fits better in the Newbie Corner), I'll add that you should put the formatting string in (single) quotes to turn it into a single argument.
I'm not saying I'm a newbie at all. The issue occurs even without any parameters to the date command.
Offline
This works fine for me:
while true; do echo $(date); sleep 1; done | dzen2"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline