LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 04-23-2013, 08:06 PM   #1
waddles
Member
 
Registered: Sep 2012
Posts: 373

Rep: Reputation: 0
Waking script from wait state


I have some shell script code where I would like to suspend, hibernate or put to sleep then on a condition have it wake up and continue. This point where I want to do this is within a designed infinite while loop which sleeps 1 second at the end of each loop. Ideally I would like to have the condition of a driver wake the slumbering code. The condition I am looking at is whether or not an interface ppp0, eth0, etc. is active.
Any suggestions for doing this? I could use "wait" to put it to sleep but haven't seen anything that could be used to wake it up like I want.

Last edited by waddles; 04-23-2013 at 08:08 PM.
 
Old 04-23-2013, 08:28 PM   #2
cortman
Member
 
Registered: Jan 2012
Location: ZZ9 Plural Z Alpha
Distribution: Crunchbang 11, LFS 7.3, DSL 4.1.10, Lubuntu 12.10, Debian 7
Posts: 219

Rep: Reputation: 43
You want the "sleep" command- it pauses for whatever interval in seconds you specify, then goes on to the next command.

Code:
echo ready in 5... ; sleep 5 ; echo seconds!
As far as having it running, why not start it and send it to the background?

Code:
./myscript &

Last edited by cortman; 04-23-2013 at 08:43 PM.
 
Old 04-23-2013, 08:54 PM   #3
waddles
Member
 
Registered: Sep 2012
Posts: 373

Original Poster
Rep: Reputation: 0
Waking script from wait state

Using "sleep" could miss an event so this is not useable here.
The same problem exists whether foreground or background.
 
Old 04-23-2013, 09:20 PM   #4
speck
Member
 
Registered: Nov 2001
Location: California
Distribution: Slackware 14.1
Posts: 271

Rep: Reputation: 54
I don't know the method you're using to determine if the interface is active, but you might want to look at inotifywait to see if it would be useful.
 
Old 04-23-2013, 09:33 PM   #5
cortman
Member
 
Registered: Jan 2012
Location: ZZ9 Plural Z Alpha
Distribution: Crunchbang 11, LFS 7.3, DSL 4.1.10, Lubuntu 12.10, Debian 7
Posts: 219

Rep: Reputation: 43
Quote:
Originally Posted by waddles View Post
Using "sleep" could miss an event so this is not useable here.
The same problem exists whether foreground or background.
My idea was that your script would *check* if the event requiring further action had occurred; i.e., according to the OP if interface eth0 was active; if eth0 was not active, the script would sleep for a second, then check again, and keep looping that way.
Maybe it'd be more helpful if you'd say what you're trying to do.
 
  


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
Current - Waking up from suspend state veeall Slackware 2 04-26-2011 11:29 AM
Simple script to wait for another script Maverick1182 Linux - Newbie 4 11-05-2007 03:45 AM
Bash script for waking bluetooth trox Linux - Newbie 4 10-14-2007 12:37 PM
How to make a script wait for input farmerjoe Linux - General 2 12-28-2004 05:18 AM
Waking up only one process from a wait queue serkult Programming 3 05-12-2004 03:12 AM


All times are GMT -5. The time now is 03:17 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration