Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Continue execution of bash script while in listening state

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
leke
LXF regular


Joined: Mon Oct 22, 2007 6:45 pm
Posts: 503
Location: Oulu, Finland

PostPosted: Wed May 26, 2010 8:51 pm    Post subject: Continue execution of bash script while in listening state Reply with quote

I wanted to automate a fairly long shell script process that kind of falls in to a listening state and then would need to open another window and execute another command. Problem is, I don't know how to run other commands after that state is reached.

Any tips?
Thanks.

Here is the script if you are interested...
Code:

hciconfig reset
sdptool add --channel=2 SP
# Connect phone's bluetooth console to PC then...

rfcomm listen rfcomm2 2
# Connection is made. Process is ongoing.

# This would open new terminal if the last command wasn't still running.
gnome-terminal -e 'cu -l /dev/rfcomm2'

_________________
http://truecenterpublishing.com/zenstory/maybe.html
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8457
Location: Warrington, UK

PostPosted: Wed May 26, 2010 9:07 pm    Post subject: Reply with quote

You could use a fifo, which works rather like a pipe but looks like a file. Something like

Code:

mkfifo /tmp/myfifo
command1 >/tmp/myfifo &

cat /tmp/myfifo | while read stuff; do
    process stuff
    done


The & on command1 backgrounds the process. Then your loop runs until command1 exits and it has read all data in the pipe.
_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
leke
LXF regular


Joined: Mon Oct 22, 2007 6:45 pm
Posts: 503
Location: Oulu, Finland

PostPosted: Fri May 28, 2010 1:04 pm    Post subject: Reply with quote

Thanks. I've still trying to understand how it works, but thanks for the info Razz I'll do some googling on the subject Wink
_________________
http://truecenterpublishing.com/zenstory/maybe.html
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
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
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast