[Diverse] Wanadoo Hometime Dail script

Pagina: 1
Acties:
  • 110 views sinds 30-01-2008
  • Reageer

  • Attilla
  • Registratie: Februari 2001
  • Laatst online: 23-06-2021
Ik vroeg me af of iemand zoiets als heeft gemaakt.
voor onder linux dus :+
En of die gene het dan wil sharen :)

Anders moet ik er zelf 1 maken maare kan ik dit met crontab doen ?

Of heeft iemand suggesties hoe dit te doen ?

Het gaat dus om wanadoo hometime met isdn en de bedoeling is dan dat ik wil dat ie elke dag automatisch inbelt om 7 uur savonds en verbreekt om 8 uur 's ochtens en vrijdagavond om 7 uur inbelt tot maandag ochtend 8 uur.
En hij moet dan ook redailen omdat hij om de 2 uur disconnect en iedere 45 sec een ping naar een nog nader bepaald adres om de connection alive te houden.

Ik vraag hier dus niet om het script zelf (naja als iemand het al heeft gemaakt >:) ) maar een paar id's (of how to's) hoe ik dit zou kunnen doen.

  • klown
  • Registratie: November 2001
  • Laatst online: 07:37

klown

geek

hmmmm
jah, dat lijkt mij ook wel interessant, ik heb nu nog een windows gateway, maar ik kan niet zeggen dat ik daar nou zo blij mee ben, als ik onder linux weet hoe ik moet redialen enzo :) hoef ik alleen m'n modem nog aan de praat te krijgen en dan kan ik ook mooi poortjes forwarden enzo B-)

MSI K7T266 Pro2|AMD Athlon XP 1800+|512 MB DDR|Leadtek Geforce 2 Ti 64 MB DDR|LG 16x DVD|IBM 60 GB 7200 rpm HD|Creative soundworks DTT3500 speakers|IIyama A902MT|Wacom Graphire 2|Logitech Mouseman Dual optical & MX500|Creative soundbl. Audigy|Trust sp


  • Attilla
  • Registratie: Februari 2001
  • Laatst online: 23-06-2021
nou met isdn kan je het neerzetten dat hij auto connect als er verkeer naar buiten is.

en nu laat ik hem steeds reconnecten door gewoon een ping elke 45sec naar mijn domein te laten lopen.

maar een script zou toch wel handiger zijn.

  • moto-moi
  • Registratie: Juli 2001
  • Laatst online: 09-06-2011

moto-moi

Ja, ik haat jou ook :w

God, root, what is difference? | Talga Vassternich | IBM zuigt


  • Attilla
  • Registratie: Februari 2001
  • Laatst online: 23-06-2021
About:
inetfeeler is a bash script developed to bring up a PPP connection when the "wireless" modem (LAN) connection fails.

:? :?

ik heb isdn

  • Attilla
  • Registratie: Februari 2001
  • Laatst online: 23-06-2021
bescheiden kickje ...

Verwijderd

nu je ico logo waar maken >:)<blockquote><font size="1" face="verdana, arial, helvetica">code:</font><hr><font face="courier, fixedsys, lucida console"><nobr>  BASH Programming - Introduction HOW-TO
  by Mike G mikkey at dynamo.com.ar
  Thu Jul 27 09:36:18 ART 2000

  This article intends to help you to start programming     basic-inter­
  mediate shell scripts. It does not intend to be an     advanced docu­
  ment (see the title). I am NOT an expert nor guru     shell program­
  mer. I decided to write this because I'll learn a     lot and it might
  be useful to other people. Any feedback will be apreciated,     spe­
  cially in the patch form :)
  ______________________________________________________________________

  Table of Contents



  1. Introduction

     1.1 Getting the latest version
     1.2 Requisites
     1.3 Uses of this document

  2. Very simple Scripts

     2.1 Traditional hello world script
     2.2 A very simple backup script

  3. All about redirection

     3.1 Theory and quick reference
     3.2 Sample: stdout 2 file
     3.3 Sample: stderr 2 file
     3.4 Sample: stdout 2 stderr
     3.5 Sample: stderr 2 stdout
     3.6 Sample: stderr and stdout 2 file

  4. Pipes

     4.1 What they are and why you'll want to use them
     4.2 Sample: simple pipe with sed
     4.3 Sample: an alternative to ls -l *.txt

  5. Variables

     5.1 Sample: Hello World! using variables
     5.2 Sample: A very simple backup script (little bit better)
     5.3 Local variables

  6. Conditionals

     6.1 Dry Theory
     6.2 Sample: Basic conditional example if .. then
     6.3 Sample: Basic conditional example if .. then ... else
     6.4 Sample: Conditionals with variables

  7. Loops for, while and until

     7.1 For sample
     7.2 C-like for
     7.3 While sample
     7.4 Until sample

  8. Functions

     8.1 Functions sample
     8.2 Functions with parameters sample

  9. User interfaces

     9.1 Using select to make simple menus
     9.2 Using the command line

  10. Misc

     10.1 Reading user input with read
     10.2 Arithmetic evaluation
     10.3 Finding bash
     10.4 Getting the return value of a program
     10.5 Capturing a commands output
     10.6 Multiple source files

  11. Tables
     11.1 String comparison operators
     11.2 String comparison examples
     11.3 Arithmetic operators
     11.4 Arithmetic relational operators
     11.5 Useful commands

  12. More Scripts

     12.1 Applying a command to all files in a directory.
     12.2 Sample: A very simple backup script (little bit better)
     12.3 File re-namer
     12.4 File renamer (simple)

  13. When something goes wrong (debugging)

     13.1 Ways Calling BASH

  14. About the document

     14.1 (no) warranty
     14.2 Translations
     14.3 Thanks to
     14.4 History
     14.5 More resources


  ______________________________________________________________________

  1.  Introduction

  1.1.  Getting the latest version

  http://www.linuxdoc.org/HOWTO/Bash-Prog-Intro-HOWTO.html



  1.2.

  Requisites

  Familiarity with GNU/Linux command lines, and familiarity with basic
  programming concepts is helpful. While this is not a programming
  introduction, it explains (or at least tries) many basic concepts.



  1.3.

  Uses of this document

  This document tries to be useful in the following situations

  ·  You have an idea about programming and you want to start coding
     some shell scripts.

  ·  You have a vague idea about shell programming and want some sort of
     reference.

  ·  You want to see some shell scripts and some comments to start
     writing your own

  ·  You are migrating from DOS/Windows (or already did) and want to
     make "batch" processes.

  ·  You are a complete nerd and read every how-to available

  2.

  Very simple Scripts

  This HOW-TO will try to give you some hints about shell script
  programming strongly based on examples.

  In this section you'll find some little scripts which will hopefully
  help you to understand some techniques.


  2.1.


  Traditional hello world script



                 #!/bin/bash
                 echo Hello World



  This script has only two lines.  The first indicates the system which
  program to use to run the file.

  The second line is the only action performed by this script, which
  prints 'Hello World' on the terminal.

  If you get something like ./hello.sh: Command not found.  Probably the
  first line '#!/bin/bash' is wrong, issue whereis bash or see

  2.2.

  A very simple backup script



               #!/bin/bash
               tar -cZf /var/my-backup.tgz /home/me/



  In this script, instead of printing a message on the terminal, we
  create a tar-ball of a user's home directory. This is NOT intended to
  be used, a more useful backup script is presented later in this
  document.

  3.

  All about redirection

  3.1.

  Theory and quick reference

  There are 3 file descriptors, stdin, stdout and stderr (std=standard).



  Basically you can:

  1. redirect stdout to a file

  2. redirect stderr to a file

  3. redirect stdout to a stderr

  4. redirect stderr to a stdout

  5. redirect stderr and stdout to a file

  6. redirect stderr and stdout to stdout

  7. redirect stderr and stdout to stderr

     1 'represents' stdout and 2 stderr.

  A little note for seeing this things: with the less command you can
  view both stdout (which will remain on the buffer) and the stderr that
  will be printed on the screen, but erased as you try to 'browse' the
  buffer.

  3.2.  Sample: stdout 2 file

  This will cause the ouput of a program to be written to a file.


               ls -l > ls-l.txt



  Here, a file called 'ls-l.txt' will be created and it will contain
  what you would see on the screen if you type the command 'ls -l' and
  execute it.

  3.3.  Sample: stderr 2 file

  This will cause the stderr ouput of a program to be written to a file.


               grep da * 2> grep-errors.txt



  Here, a file called 'grep-errors.txt' will be created and it will con­
  tain what you would see the stderr portion of the output of the 'grep
  da *' command.

  3.4.

  Sample: stdout 2 stderr

  This will cause the stderr ouput of a program to be written to the
  same filedescriptor than stdout.


               grep da * 1>&2



  Here, the stdout portion of the command is sent to stderr, you may
  notice that in differen ways.

  3.5.  Sample: stderr 2 stdout

  This will cause the stderr ouput of a program to be written to the
  same filedescriptor than stdout.


               grep * 2>&1



  Here, the stderr portion of the command is sent to stdout, if you pipe
  to less, you'll see that lines that normally 'dissapear' (as they are
  written to stderr) are being kept now (because they're on stdout).

  3.6.  Sample: stderr and stdout 2 file

  This will place every output of a program to a file. This is suitable
  sometimes for cron entries, if you want a command to pass in absolute
  silence.


               rm -f $(find / -name core) &> /dev/null



  This (thinking on the cron entry) will delete every file called 'core'
  in any directory. Notice that you should be pretty sure of what a com­
  mand is doing if you are going to wipe it's output.

  4.

  Pipes

  This section explains in a very simple and practical way how to use
  pipes, nd why you may want it.


  4.1.

  What they are and why you'll want to use them

  Pipes let you use (very simple, I insist) the output of a program as
  the input of another one

  4.2.  Sample: simple pipe with sed

  This is very simple way to use pipes.


               ls -l | sed -e "s/[aeio]/u/g"



  Here, the following happens: first the command ls -l is executed, and
  it's output, instead of being printed, is sent (piped) to the sed pro­
  gram, which in turn, prints what it has to.

  4.3.  Sample: an alternative to ls -l *.txt

  Probably, this is a more difficult way to do ls -l *.txt, but it is
  here for illustrating pipes, not for solving such listing dilema.


               ls -l | grep "\.txt$"



  Here, the output of the program ls -l is sent to the grep program,
  which, in turn, will print lines which match the regex "\.txt$".

  5.


  Variables

  You can use variables as in any programming languages.  There are no
  data types. A variable in bash can contain a number, a character, a
  string of characters.

  You have no need to declare a variable, just assigning a value to its
  reference will create it.



  5.1.

  Sample: Hello World! using variables



                   #!/bin/bash
                   STR="Hello World!"
                   echo $STR



  Line 2 creates a variable called STR and assigns the string "Hello
  World!" to it. Then the VALUE of this variable is retrieved by putting
  the '$' in at the beginning. Please notice (try it!)  that if you
  don't use the '$' sign, the output of the program will be different,
  and probably not what you want it to be.

  5.2.

  Sample: A very simple backup script (little bit better)



                  #!/bin/bash
                  OF=/var/my-backup-$(date +%Y%m%d).tgz
                  tar -cZf $OF /home/me/



  This script introduces another thing. First of all, you should be
  familiarized with the variable creation and assignation on line 2.
  Notice the expression If you run the script you'll notice that it runs
  the command inside the parenthesis, capturing its output.


  Notice that in this script, the output filename will be different
  every day, due to the format switch to the date command(+%Y%m%d).  You
  can change this by specifying a different format.

  Some more examples:

  echo ls

  echo $(ls)

  5.3.

  Local variables

  Local variables can be created by using the keyword local.



                       #!/bin/bash
                       HELLO=Hello
                       function hello {
                               local HELLO=World
                               echo $HELLO
                       }
                       echo $HELLO
                       hello
                       echo $HELLO



  This example should be enought to show how to use a local variable.

  6.

  Conditionals

  Conditionals let you decide whether to perform an action or not, this
  decision is taken by evaluating an expression.


  6.1.

  Dry Theory

  Conditionals have many forms. The most basic form is: if expression
  then statement where 'statement' is only executed if 'expression'
  evaluates to true.  evaluates to true.xs

  Conditionals have other forms such as: if expression then statement1
  else statement2.  Here 'statement1' is executed  if 'expression' is
  true,otherwise

  Yet another form of conditionals is: if expression1 then statement1
  else if expression2 then statement2 else statement3.  In this form
  there's added only the "ELSE IF 'expression2' THEN 'statement2'" which
  makes statement2 being executed if expression2 evaluates to true. The
  rest is as you may imagine (see previous forms).

  A word about syntax:

  The base for the 'if' constructions in bash is this:

  if [expression];

  then

  code if 'expression' is true.

  fi

  6.2.

  Sample: Basic conditional example if .. then



                   #!/bin/bash
                   if [ "foo" = "foo" ]; then
                      echo expression evaluated as true
                   fi



  The code to be executed if the expression within braces is true can be
  found after the 'then' word and before 'fi' which indicates the end of
  the conditionally executed code.

  6.3.

  Sample: Basic conditional example if .. then ... else



                   #!/bin/bash
                   if [ "foo" = "foo" ]; then
                      echo expression evaluated as true
                   else
                      echo expression evaluated as false
                   fi



  6.4.

  Sample: Conditionals with variables



                   #!/bin/bash
                   T1="foo"
                   T2="bar"
                   if [ "$T1" = "$T2" ]; then
                       echo expression evaluated as true
                   else
                       echo expression evaluated as false
                   fi


  7.


  Loops for, while and until

  In this section you'll find for, while and until loops.

  The for loop is a little bit different from other programming
  languages. Basically, it let's you iterate over a series of

  The while executes a piece of code if the control expression is true,
  and only stops when it is false (or a explicit break is found within
  the executed code.

  The until loop is almost equal to the while loop, except that the code
  is executed while the control expression evaluates to false.

  If you suspect that while and until are very similar you are right.


  7.1.

  For sample



               #!/bin/bash
               for i in $( ls ); do
                   echo item: $i
               done



  On the second line, we declare i to be the variable that will take the
  different values contained in $( ls ).

  The third line could be longer if needed, or there could be more lines
  before the done (4).

  finished and $i can take a new value.

  This script has very little sense, but a more useful way to use the
  for loop would be to use it to match only certain files on the
  previous example


  7.2.

  C-like for

  fiesh suggested adding this form of looping. It's a for loop more
  similar to C/perl... for.


               #!/bin/bash
               for i in `seq 1 10`;
               do
                       echo $i
               done


  7.3.

  While sample



                #!/bin/bash
                COUNTER=0
                while [  $COUNTER -lt 10 ]; do
                    echo The counter is $COUNTER
                    let COUNTER=COUNTER+1
                done



  This script 'emulates' the well known (C, Pascal, perl, etc) 'for'
  structure

  7.4.

  Until sample



                #!/bin/bash
                COUNTER=20
                until [  $COUNTER -lt 10 ]; do
                    echo COUNTER $COUNTER
                    let COUNTER-=1
                done



  8.

  Functions

  As in almost any programming language, you can use functions to group
  pieces of code in a more logical way or practice the divine art of
  recursion.

  Declaring a function is just a matter of writing function my_func {
  my_code }.

  Calling a function is just like calling another program, you just
  write its name.


  8.1.

  Functions sample



             #!/bin/bash
             function quit {
                 exit
             }
             function hello {
                 echo Hello!
             }
             hello
             quit
             echo foo



  Lines 2-4 contain the 'quit' function. Lines 5-7 contain the 'hello'
  function If you are not absolutely sure about what this script does,
  please try it!.

  Notice that a functions don't need to be declared in any specific
  order.

  When running the script you'll notice that first: the function 'hello'
  is called, second the 'quit' function, and the program never reaches
  line 10.

  8.2.

  Functions with parameters sample



                       #!/bin/bash
                       function quit {
                          exit
                       }
                       function e {
                           echo $1
                       }
                       e Hello
                       e World
                       quit
                       echo foo



  This script is almost identically to the previous one. The main
  difference is the funcion 'e'. This function, prints the first
  argument it receives.  Arguments, within funtions, are treated in the
  same manner as arguments given to the script.

  9.


  User interfaces

  9.1.

  Using select to make simple menus



             #!/bin/bash
             OPTIONS="Hello Quit"
             select opt in $OPTIONS; do
                 if [ "$opt" = "Quit" ]; then
                  echo done
                  exit
                 elif [ "$opt" = "Hello" ]; then
                  echo Hello World
                 else
                  clear
                  echo bad option
                 fi
             done



  If you run this script you'll see that it is a programmer's dream for
  text based menus. You'll probably notice that it's very similar to the
  'for' construction, only rather than looping for each 'word' in
  $OPTIONS, it prompts the user.


  9.2.  Using the command line



                 #!/bin/bash
                 if [ -z "$1" ]; then
                     echo usage: $0 directory
                     exit
                 fi
                 SRCD=$1
                 TGTD="/var/backups/"
                 OF=home-$(date +%Y%m%d).tgz
                 tar -cZf $TGTD$OF $SRCD



  What this script does should be clear to you. The expression in the
  first conditional tests if the program has received an argument ($1)
  and quits if it didn't, showing the user a little usage message.  The
  rest of the script should be clear at this point.

  10.

  Misc

  10.1.

  Reading user input with read

  In many ocations you may want to prompt the user for some input, and
  there are several ways to achive this. This is one of those ways:



                  #!/bin/bash
                  echo Please, enter your name
                  read NAME
                  echo "Hi $NAME!"



  As a variant, you can get multiple values with read, this example may
  clarify this.


                       #!/bin/bash
                       echo Please, enter your firstname and lastname
                       read FN LN
                       echo "Hi! $LN, $FN !"



  10.2.

  Arithmetic evaluation

  On the command line (or a shell) try this:

  echo 1 + 1

  If you expected to see '2' you'll be disappointed. What if you want
  BASH to evaluate some numbers you have? The solution is this:

  echo $((1+1))

  This will produce a&amp

  • Attilla
  • Registratie: Februari 2001
  • Laatst online: 23-06-2021
ok mijn volgende post zal pas over 2 jaar zijn voor dat ik het afheb >:) tnx

  • moto-moi
  • Registratie: Juli 2001
  • Laatst online: 09-06-2011

moto-moi

Ja, ik haat jou ook :w

Op dinsdag 05 februari 2002 08:11 schreef Attilla het volgende:
About:
inetfeeler is a bash script developed to bring up a PPP connection when the "wireless" modem (LAN) connection fails.
ik heb isdn
Ik zei ook niet, dat het in een keer zou werken :D
Je zal hem wat moeten tweaken, maar dat mag nooit zo moeilijk zijn..

Ten again, ik kwam zonet deze tegen.. Misschien is dat wat ?

Je moet dan wel ff inetfeeler downloaden, en de cronscriptjes ff aanpassen denk ik.. * moto-moi zou er ook wel voor je naar willen kijken, maar ik heb sinds een tijdje kabel :)

God, root, what is difference? | Talga Vassternich | IBM zuigt


  • Mior
  • Registratie: Maart 2000
  • Laatst online: 15-08 00:58
Op dinsdag 05 februari 2002 15:58 schreef Conar het volgende:
Was dat nodig?

Post dan een linkje of zo.

  • Robert
  • Registratie: Juni 2000
  • Laatst online: 17-08 22:26

Robert

You have your answer..

eerst pppd aan de praat krijgt, wat niet al te moeilijk moet zijn; http://www.xs4all.nl/~wbsoft/linux/pppd.html

dan een automatisch task maken dat ie met cron gewoon om 7 uur pppd uitvoert, en om s'ochtends killall -9 pppd .

lijkt me niet zoveel moeilijks aan ?

zit er zelf ook beetje mee te klooien dat ik nog een mooi pictogrammetje op mijn desktop krijg, of ik offline/online ben e.d. :)

Just 'cause I'm paranoid doesn't mean they're not after me | The only operating system that does what you want: LFS


  • T006
  • Registratie: Oktober 2000
  • Laatst online: 14-08 14:43
Op dinsdag 05 februari 2002 18:30 schreef Robert het volgende:
eerst pppd aan de praat krijgt, wat niet al te moeilijk moet zijn; http://www.xs4all.nl/~wbsoft/linux/pppd.html

dan een automatisch task maken dat ie met cron gewoon om 7 uur pppd uitvoert, en om s'ochtends killall -9 pppd .

lijkt me niet zoveel moeilijks aan ?

zit er zelf ook beetje mee te klooien dat ik nog een mooi pictogrammetje op mijn desktop krijg, of ik offline/online ben e.d. :)
Het kan ook mooier natuurlijk :)
Want als het het weekend is dan wordt ie als nog opgehangen als je elke ochtend killall -9 pppd doet.


Ik heb hier Friaco en heb zo'n scriptje gemaakt om vanaf 18:01 tot 7:59 online te zijn en in het weekend.

#!/bin/bash
dag=`date +%a`
weekend="false"
if [ $dag = "Sat" ]; then
weekend="true"
fi
if [ $dag = "Sun" ]; then
weekend="true"
fi
if [ $weekend = "true" ]; then
echo -e " Het is weekend dus lijn blijft open !!!!"
else
echo -e " Het is geen weekend dus de lijn word opgehangen"
/usr/sbin/isdnctrl dialmode ippp0 manual
/usr/sbin/isdnctrl hangup ippp0
/sbin/route del default netmask 0 ippp0
fi


En ook laat ik om 18:01 met de crontab de dialmode van ippp0 op auto zetten zodat ie automatisch gaat bellen (ook bij disconnects).

Suc6

  • Attilla
  • Registratie: Februari 2001
  • Laatst online: 23-06-2021
Op dinsdag 05 februari 2002 19:33 schreef T006 het volgende:

[..]

Het kan ook mooier natuurlijk :)
Want als het het weekend is dan wordt ie als nog opgehangen als je elke ochtend killall -9 pppd doet.


Ik heb hier Friaco en heb zo'n scriptje gemaakt om vanaf 18:01 tot 7:59 online te zijn en in het weekend.

#!/bin/bash
dag=`date +%a`
weekend="false"
if [ $dag = "Sat" ]; then
weekend="true"
fi
if [ $dag = "Sun" ]; then
weekend="true"
fi
if [ $weekend = "true" ]; then
echo -e " Het is weekend dus lijn blijft open !!!!"
else
echo -e " Het is geen weekend dus de lijn word opgehangen"
/usr/sbin/isdnctrl dialmode ippp0 manual
/usr/sbin/isdnctrl hangup ippp0
/sbin/route del default netmask 0 ippp0
fi


En ook laat ik om 18:01 met de crontab de dialmode van ippp0 op auto zetten zodat ie automatisch gaat bellen (ook bij disconnects).

Suc6
kijk hier heb ik wat aan (niet dat ik niks aan de rest had ofzow)

ik heb je ook geadd icq dat vind ik wat makkelijker

  • Gilles
  • Registratie: Februari 2000
  • Laatst online: 28-07-2025
Ja hoor lekker bezig...
Zometeen post je natuurlijk weer een of ander kutscript hier. Vervolgens gaat iedereen dit gebruiken, en binnen een maand gaat Wanadoo paal en perk stellen aan het aantal uren per dag. Nou.. Alvast bedankt he!

  • Attilla
  • Registratie: Februari 2001
  • Laatst online: 23-06-2021
Op dinsdag 05 februari 2002 20:16 schreef gilles het volgende:
Ja hoor lekker bezig...
Zometeen post je natuurlijk weer een of ander kutscript hier. Vervolgens gaat iedereen dit gebruiken, en binnen een maand gaat Wanadoo paal en perk stellen aan het aantal uren per dag. Nou.. Alvast bedankt he!
Nou goed ik maak gewoon gebruik van waarvoor ik betaal..
Dat vind ik geen schande.

En die programma's zijn er al lang.

oa. Microsoft's Windows Alle versies daar kan het mee.

dusse ik vind dat je niet zo moet lullen.

Verwijderd

Op dinsdag 05 februari 2002 18:00 schreef Phantom het volgende:

[..]

Was dat nodig?

Post dan een linkje of zo.
ja dat was nodig,
'k had alleen een docje 8-)

  • BezurK
  • Registratie: Juni 2001
  • Laatst online: 14-06 09:12
Ik ben crontab newbie, hoe laat ik crontab elke dag om 7:59 die script uitvoeren en hoe laat ik me server elke dag (behalve in weekends dan, maar dialen over dialen gebeurt niets denk ik, foutmelding ofzow) om 18:00 inbellen?

Rookworst zonder R is ook worst.


  • imdos
  • Registratie: Maart 2000
  • Laatst online: 05-08 12:09

imdos

I use FreeNAS and Ubuntu

man cron |:( :Z

Maargoed iets als

59 7 * * * /path/to/script >/dev/null &2>&1
* 18 * * * /path/to/ander_script >/dev/null &2>&1

overigens kan je met date wel iets met een dagindeling fixen denk ik .. dus kan je het ook in een script houden, of met een case werken. P.S. dit is slechts voor de overzichtelijkheid zodat je alles op een plek hebt. Er is niets op tegen om 2 of meerdere scripts te maken! :)

Maar ga maar eens een bash howto doorlezen voordat ik alles voorkouw!

pvoutput. Waarom makkelijk doen, als het ook moeilijk kan! Every solution has a new problem


  • Attilla
  • Registratie: Februari 2001
  • Laatst online: 23-06-2021
Dusse zoiets zou het moeten fixen allemaal.

#!/bin/bash
#dag=$1
#tijd=$1
dag=`date +%a`
tijd=`date +%H%M`
daluur="false"
weekend="false"
if [ $dag = "Sat" or $dag = "Sun" ]; then
weekend="true"
fi
if [ $tijd -gt "1900" ]; then
if [ $tijd -lt "0800" ]; then
daluur="true"
fi
fi
if [ $weekend = "true" or $daluur = "true"]; then
echo -e " Het is weekend of daluur dus lijn blijft open !!!!"
else
echo -e " Het is geen weekend of je zit niet in de daluren dus de lijn word opgehangen"
/usr/sbin/isdnctrl dialmode ippp0 manual
/sbin/route del default netmask 0 ippp0
fi

#!/bin/bash
/usr/sbin/isdnctrl dial ippp0
sleep 7
/sbin/route add default netmask 0 ippp0


En dan gewoon iedere 5 minuten een crontab laten lopen met dit script en vast om 19.00 en 8.01 laten lopen.

  • T006
  • Registratie: Oktober 2000
  • Laatst online: 14-08 14:43
Op donderdag 07 februari 2002 19:14 schreef Attilla het volgende:
Dusse zoiets zou het moeten fixen allemaal.

#!/bin/bash
#dag=$1
#tijd=$1
dag=`date +%a`
tijd=`date +%H%M`
daluur="false"
weekend="false"
if [ $dag = "Sat" or $dag = "Sun" ]; then
weekend="true"
fi
if [ $tijd -gt "1900" ]; then
if [ $tijd -lt "0800" ]; then
daluur="true"
fi
fi
if [ $weekend = "true" or $daluur = "true"]; then
echo -e " Het is weekend of daluur dus lijn blijft open !!!!"
else
echo -e " Het is geen weekend of je zit niet in de daluren dus de lijn word opgehangen"
/usr/sbin/isdnctrl dialmode ippp0 manual
/sbin/route del default netmask 0 ippp0
fi

#!/bin/bash
/usr/sbin/isdnctrl dial ippp0
sleep 7
/sbin/route add default netmask 0 ippp0


En dan gewoon iedere 5 minuten een crontab laten lopen met dit script en vast om 19.00 en 8.01 laten lopen.
Om 19:00 en 7:59 moet genoeg zijn en bij jouw hangt ie niet op :) zie namelijk nergens isdnctrl hangup ippp0
Om de 5 min is overdreven omdat de dialmode op auto staat dus als er een disconnect is dan belt ie automatisch weer in.

  • Attilla
  • Registratie: Februari 2001
  • Laatst online: 23-06-2021
Maar is het niet makkelijker om 2 scripts te maken...

de ene om 1900 laten lopen

en de andere om 7.59

want hij pakt dit nu niet goed :)

en die hangup die copy paste net niet mee

  • T006
  • Registratie: Oktober 2000
  • Laatst online: 14-08 14:43
Ik gebruik twee scripts ja... eentje om in te bellen en eentje om te kijken of de verbinding verbroken moet worden.

  • Attilla
  • Registratie: Februari 2001
  • Laatst online: 23-06-2021
Nou het script werkt die kunnen jullie nou allemaal gebruiken :)

#!/bin/bash
#dal=$1
#weekend=$1
dag=$(date +%a)
tijd=$(date +%H%M)
dal="false"
weekend="false"

if [ $dag = "Sat" ] || [ $dag = "Sun" ]; then
weekend="true"
else
weekend="false"
fi
if [ $tijd -gt "1858" ] || [ $tijd -lt "0759" ]; then
dal="true"
fi
if [ $tijd -lt "1858" ] && [ $tijd -gt "0759" ]; then
dal="false"
fi
if [ $weekend = "true" ] || [ $dal = "true" ]; then
echo -e " Het is weekend of daluur dus je mag internetten !!!!"
/usr/sbin/isdnctrl dial ippp0
sleep 7
/sbin/route add default netmask 0 ippp0
/usr/sbin/isdnctrl dialmode ippp0 automatic
else
echo -e " Het is geen weekend of daluur dus je mag niet
internetten"
/usr/sbin/isdnctrl dialmode ippp0 manual
/usr/sbin/isdnctrl hangup ippp0
/sbin/route del default netmask 0 ippp0
fi


Deze kan je gewoon in inbel.sh doen ofzow chmod 700 eroverheen.

in een crontab draaien om 1900 en 0759 en je hebt een perfecte wanadoo hometime (of tijden veranderen voor friaco) inbel server (samen met ipchains etc.) uiteraard met een werkende isdn verbinding.

Met vriendelijke dank aan T006 en MGP (mun neefje ik moest van hem zun naam erbij zetten) :P
Pagina: 1