UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old December 20th, 2004, 06:55 AM
SysAd_babe SysAd_babe is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Philippines
Posts: 14 SysAd_babe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 22 sec
Reputation Power: 0
Question loop script

Hi,

I have to create a shell script that will loop every 5minutes and will check if file.txt exists. If file.txt exists, it will call another shell script to execute. Kindly help me, what looping technique should i use.

Thanx.

Reply With Quote
  #2  
Old December 20th, 2004, 07:00 AM
fpmurphy fpmurphy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: USA
Posts: 257 fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level)fpmurphy User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 23 h 46 sec
Reputation Power: 6
Using pseudocode:

Code:
    while TRUE
    do
          check file status & do something if condition meet
          sleep 360 seconds
    done

Reply With Quote
  #3  
Old December 20th, 2004, 07:35 AM
SysAd_babe SysAd_babe is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Philippines
Posts: 14 SysAd_babe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 22 sec
Reputation Power: 0
does this also apply in unix shell script?

Thanks

Reply With Quote
  #4  
Old December 20th, 2004, 12:35 PM
Perderabo Perderabo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 121 Perderabo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 54 sec
Reputation Power: 5
The potential trouble with fpmurphy's technique is that "something" might not consume the file. So we stay in the loop, sleep again, and do "something" again. This may be what is needed. Or we might want to do "something" just once:
Code:
while FILE DOES NOT EXIST
do
        sleep 300
done
run second script
exit

And again this is psuedo-code to simply illustrate the looping technique. It applies to all languages incuding most shells. Specific syntax is not possible since there are many languages including several shells.

Reply With Quote
  #5  
Old December 21st, 2004, 02:15 AM
SysAd_babe SysAd_babe is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Philippines
Posts: 14 SysAd_babe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 22 sec
Reputation Power: 0
Thanx so much

Reply With Quote
  #6  
Old December 22nd, 2004, 07:52 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 33 m 4 sec
Reputation Power: 9
The potential trouble with perderabo's technique is that
it will run once (if the second does not (re)call the first script)
is this the Q ?

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > loop script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway