Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 29 Jul 2014, 21:30
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
.
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [9 Posts]  
Author Message
simargl

Joined: 11 Feb 2013
Posts: 572

PostPosted: Wed 15 May 2013, 06:40    Post subject:  .  

.
Last edited by simargl on Sun 01 Sep 2013, 12:04; edited 3 times in total
Back to top
View user's profile Send private message Visit poster's website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3956
Location: Kiel,Germany

PostPosted: Wed 15 May 2013, 07:24    Post subject:  

probably try to use grep -m1 or grep | tail -n1 so if more than one line in /tmp/output it piks the first or the last , so if tail at the very end might be already get one single line after all the sed edits .

cat /tmp/output | grep is seen everywhere, but grep /tmp/output should do it also .
Back to top
View user's profile Send private message Visit poster's website 
simargl

Joined: 11 Feb 2013
Posts: 572

PostPosted: Wed 15 May 2013, 08:09    Post subject:  

.
Last edited by simargl on Sun 01 Sep 2013, 11:09; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3956
Location: Kiel,Germany

PostPosted: Wed 15 May 2013, 08:15    Post subject:  

Quote:
while [ "$(pidof yad)" ]; do

Sometimes seems not to work as it could.
Probably missing a break, since the test for "$(pidof yad)" might only run once at while begin.
Probably needs additionally a
[ "$(pidof yad)" ] || break
inside it to stop the current loop. Otherwise you'll probably have multiple instances of the while loop running .
like
Code:
while [ "$(pidof yad)" ]; do
  sleep 5s
  [ -f /tmp/output ] || break
  [ "$(pidof yad)" ] || break
  NEW_TITLE=$(grep 'StreamTitle' /tmp/output | tail -n1 | sed 's|ICY Info: StreamTitle=||g' | sed 's/;[^-]*$//' | sed s/"'"/" "/g)
  if [[ "$NEW_TITLE" != "$TITLE" ]]; then
    notify-send -i simple-radio "$action" "$NEW_TITLE"
    TITLE="$NEW_TITLE"
  fi
done
Back to top
View user's profile Send private message Visit poster's website 
simargl

Joined: 11 Feb 2013
Posts: 572

PostPosted: Wed 15 May 2013, 08:32    Post subject:  

.
Last edited by simargl on Sun 01 Sep 2013, 11:09; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3956
Location: Kiel,Germany

PostPosted: Wed 15 May 2013, 10:48    Post subject:  

No GUI freak here, and know nothing about yad.

You have yad GUI and yad --notification .

Probably this is confusing things , so running a new instance of the yad gui would prevent the loop from exiting/breaking.

Otherwise yad --notification might need killall -9 which almost every time succeeds .

You should remove the >/dev/null s to have a better view on things .
Back to top
View user's profile Send private message Visit poster's website 
PANZERKOPF

Joined: 16 Dec 2009
Posts: 280
Location: Earth

PostPosted: Wed 15 May 2013, 11:47    Post subject: Re: lost inside while loop  

simargl wrote:
like variable $action

IIRC:
Loop runs as a separate process so all variables inside it are not visible by parent process.

_________________
SUUM CUIQUE.
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4284

PostPosted: Thu 16 May 2013, 01:30    Post subject:  

Please don't poll for file changes.
Code:
touch /tmp/file #make sure it exists
inotifyd - /tmp/file:c |while read DUMMY; do
    echo actions to do when file is changed
done &

inotifyd will be dormant (using almost no resources) until awakened by an inotify event from the kernel (no polling) - you can get 500 events in 1 second or have the process running dormant for days and it would pop right up as soon as the file changes
Note: inotifyd can monitor stuff other than just changes (:c) including entire directories

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
simargl

Joined: 11 Feb 2013
Posts: 572

PostPosted: Thu 16 May 2013, 03:45    Post subject:  

.
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [9 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0555s ][ Queries: 11 (0.0049s) ][ GZIP on ]