]> git.ozlabs.org Git - ppp.git/blob - NeXT/Examples/redial.sh
Cosmetic fix.
[ppp.git] / NeXT / Examples / redial.sh
1 #!/bin/csh
2 # Script for multiple redialing to bring up PPP connection.
3 # Written by Colin.Allen@tamu.edu
4 # I make no warranties about this script, but if you have suggestions
5 # for improving it please feel free to email them to me.
6
7 # Last modified 11-29-95
8
9 if ( -f /usr/local/ppp/etc/ppp0.pid ) then
10
11 # The ppp0.pid file should only exist with an active ppp connection
12 # in which case we don't want to try to dial out. Sometimes the file
13 # will need to be deleted manually if ppp was dropped abnormally.
14
15         echo ERROR: PPP already running.
16         set quit = y
17 else
18         set quit = n
19         set count = 0
20         set limit = 500
21         set script = pppup
22
23 endif
24
25 while ( $quit != y );
26
27 # Next we loop as long as we are not quitting.  Each circuit we check
28 # for a connection and if it's there we launch PopOver.
29 # Delete or add other programs as desired.
30
31         if ( -f /usr/local/ppp/etc/ppp0.pid ) then
32                 set quit = y
33                 echo Connected after $count attempts.
34                 echo -n "Launching PopOver...Process id: "
35                 nohup /LocalApps/PopOver.app/PopOver &
36                 echo Done.
37
38 # If the connection is not there we ascertain whether the modem is
39 # still trying to get a connection by looking to see if "chat" appears
40 # in the output of ps.  It is bound to appear at least once because ps
41 # will find the grep process.  If it appears exactly once then any
42 # previous connection attempt has failed and we need to allow time
43 # for the modem to reset, then we are free to dial again.
44
45 # You may be able to optimize this script by adjusting the sleep values
46 # below.  My modem (a ZyXEL 1496E) takes about 8 seconds to reset after
47 # hanging up.
48
49         else
50                 set chat =  `ps | grep -c chat`
51                 if ( $chat == 1 ) then
52                         if ( $count != 0 ) then
53                                 echo "no connect"
54                                 sleep 8
55                         endif
56                         @ count++
57                         if ( $count == $limit ) then
58                                 echo "Dial count over limit.  Aborting."
59                                 set quit = y
60                         else
61                                 /usr/local/ppp/scripts/$script
62                                 echo -n "($count) Dialing..."
63                                 sleep 5
64                                 echo -n "trying to connect..."
65                                 sleep 5
66                         endif
67                 else
68
69 # If chat is still working we just wait a bit and loop again.
70
71                         echo -n "."
72                         sleep 5
73                 endif
74         endif
75 end
76