Results 1 to 20 of 20

Thread: Rebooting Modem In Ubuntu(Linux)

  1. #1
    Silver Member
    Join Date
    Apr 2008
    Age
    25
    Liked
    0 times
    Posts
    418

    Question Automatic Rebooting of Modem In Ubuntu(Linux)

    Hello everyone ,

    My modem type is ZTE ZXDSL 831 AII ......... and my plan is HOME 500C
    so i have a download limit of 1.5 GB as well as free usage during 2:00a.m. to 8:00 a.m. .......... so i wanted to schedule my modem to reboot at 2:05 a.m. in the morning automatically by scheduling the task ............ i'm having Ubuntu ..........
    could somebody please guide me as too how to figure it up ...........

    thnxxx in advance ........
    Last edited by eruptionjoojo; 03-25-09 at 10:41 PM.

  2. #2
    Platinum Member
    Join Date
    Feb 2008
    Liked
    0 times
    Posts
    2,766

    Default

    theres a tool called expect in ubuntu which you can use to reboot your modem , you need to design a script for that.. to install expect type sudo apt-get install expect . i dont have the script with me right now , as im not at home , but will post soon..

  3. #3
    Silver Member
    Join Date
    Apr 2008
    Age
    25
    Liked
    0 times
    Posts
    418

    Smile

    Quote Originally Posted by superprash2003 View Post
    theres a tool called expect in ubuntu which you can use to reboot your modem , you need to design a script for that.. to install expect type sudo apt-get install expect . i dont have the script with me right now , as im not at home , but will post soon..
    thnxx bro for the reply ........
    i will try it and give you feedbacks about it ............

  4. #4
    Silver Member
    Join Date
    Dec 2008
    Liked
    0 times
    Posts
    370

    Default

    You can try the solution specified by superprash2003. In any Linux you can schedule jobs using cron. Anyway you have do the necessary telnet script and the same can be executed as a cron job. In cron you can define the frequency of execution like hourly, daily, etc. My plan also 500C and I am using Mandriva 2009 as I like the simplicity. It is like in windows world for my children. But I rarely d/l so never tried scheduling modem reboot.

  5. #5
    Silver Member
    Join Date
    Apr 2008
    Age
    25
    Liked
    0 times
    Posts
    418

    Question

    @superprash

    I have installed expect by typing the command in the terminal ................

    Quote Originally Posted by matrix View Post
    You can try the solution specified by superprash2003. In any Linux you can schedule jobs using cron. Anyway you have do the necessary telnet script and the same can be executed as a cron job. In cron you can define the frequency of execution like hourly, daily, etc. My plan also 500C and I am using Mandriva 2009 as I like the simplicity. It is like in windows world for my children. But I rarely d/l so never tried scheduling modem reboot.
    I have installed cron ................ but i don't know why while i search for it directly it is not to be found ............... but while on the contrary while i check it in the package manager like synaptic,adept etc. it shows already installed ................ i really don't know what the problem is ..............
    Last edited by eruptionjoojo; 03-27-09 at 05:24 AM. Reason: Automerged Doublepost

  6. #6
    Silver Member
    Join Date
    Dec 2008
    Liked
    0 times
    Posts
    370

    Default

    Cron is installed by default. You just need to make the script. You may use webmin (browser based admin tool) to schedule the job.

    Have you tried expect as suggested by superprash2003? I never used that one.

  7. #7
    Silver Member
    Join Date
    Apr 2008
    Age
    25
    Liked
    0 times
    Posts
    418

    Smile

    Quote Originally Posted by matrix View Post
    Cron is installed by default. You just need to make the script. You may use webmin (browser based admin tool) to schedule the job.

    Have you tried expect as suggested by superprash2003? I never used that one.

    thnxxx for your reply ....................
    superprash did suggest me to install the expect and i have installed it as well ............... but haven't received the script from him ............. so have yet to try it out.

  8. #8
    Silver Member
    Join Date
    Apr 2008
    Age
    25
    Liked
    0 times
    Posts
    418

    Unhappy

    can somebody please provide me with the script to reboot my modem in kubuntu(linux) ................ i really need it .............
    thnxx in advance ..............

  9. #9
    Platinum Member
    Join Date
    Feb 2008
    Liked
    0 times
    Posts
    2,766

    Default

    here's the script .. hope it helps..

    #!/usr/bin/expect -f



    # router user name
    set name "admin"

    # router password
    set pass "admin"

    # router IP address
    set routerip "192.168.1.1"

    # Read command as arg to this script
    set routercmd [lindex $argv 0]

    # start telnet
    spawn telnet $routerip

    # send username & password
    expect "Login:"
    send -- "$name\n"
    expect "Password:"
    send -- "$pass\n"

    # get out of ISP's Stupid menu program, go to shell
    expect " -> "
    send -- "reboot\n"

    # execute command
    expect "# "
    send -- "$routercmdr"
    # exit
    send -- "^D"

  10. #10
    Silver Member
    Join Date
    Apr 2008
    Age
    25
    Liked
    0 times
    Posts
    418

    Post

    Quote Originally Posted by superprash2003 View Post
    here's the script .. hope it helps..

    #!/usr/bin/expect -f



    # router user name
    set name "admin"

    # router password
    set pass "admin"

    # router IP address
    set routerip "192.168.1.1"

    # Read command as arg to this script
    set routercmd [lindex $argv 0]

    # start telnet
    spawn telnet $routerip

    # send username & password
    expect "Login:"
    send -- "$name\n"
    expect "Password:"
    send -- "$pass\n"

    # get out of ISP's Stupid menu program, go to shell
    expect " -> "
    send -- "reboot\n"

    # execute command
    expect "# "
    send -- "$routercmdr"
    # exit
    send -- "^D"
    thnxx a lot bro ............
    but i'm confused as to where to type this script and how to schedule it using cron or expect ............... please help me i'm just a n00b in linux .........

  11. #11
    Platinum Member
    Join Date
    Feb 2008
    Liked
    0 times
    Posts
    2,766

    Default

    ok..here goes.. small tutorial .. hopefully i can put it on the blog soon .. copy and paste the above code into text editor ( applications->accessories).. then save it as router.exp and place it in your home folder.. for example : /home/prash . so the link to the file would be /home/prash/router.exp . Now go to the terminal ( applications->accessories) . and type crontab -e

    Then add the following 2 lines .

    15 2 * * * /home/prash/router.exp
    45 7 * * * /home/prash/router.exp


    Once done adding those lines . press CTRL+X and then press Y ( to save changes ).
    Here replace /home/prash with your home folder link . the first line reboots your router at 2:15 and the second line again at 7:45am . this is for the night unlimited . This script works for ut300r2u . For huawei modems i think you need to use system_restart instead of reboot..

  12. #12
    Silver Member
    Join Date
    Apr 2008
    Age
    25
    Liked
    0 times
    Posts
    418

    Smile

    Quote Originally Posted by superprash2003 View Post
    ok..here goes.. small tutorial .. hopefully i can put it on the blog soon .. copy and paste the above code into text editor ( applications->accessories).. then save it as router.exp and place it in your home folder.. for example : /home/prash . so the link to the file would be /home/prash/router.exp . Now go to the terminal ( applications->accessories) . and type crontab -e

    Then add the following 2 lines .

    15 2 * * * /home/prash/router.exp
    45 7 * * * /home/prash/router.exp


    Once done adding those lines . press CTRL+X and then press Y ( to save changes ).
    Here replace /home/prash with your home folder link . the first line reboots your router at 2:15 and the second line again at 7:45am . this is for the night unlimited . This script works for ut300r2u . For huawei modems i think you need to use system_restart instead of reboot..
    thnxx a lot for your reply bro .............
    actually i have another script for rebooting which i got from a blog ............
    but the problem which i was facing was that after adding the entries into the cron tab i had no idea as to how to save it ................ so as you have addressed the issue in this post of your's i think now i would be able to reboot my modem successfully .................
    so thnxx again ............... anyways if i'm still not successful i would trouble you again bro .......
    hopefully you don't mind .........

  13. #13
    Platinum Member
    Join Date
    Feb 2008
    Liked
    0 times
    Posts
    2,766

    Default

    sure..anytime ..

  14. #14
    Silver Member
    Join Date
    Apr 2008
    Age
    25
    Liked
    0 times
    Posts
    418

    Unhappy

    Quote Originally Posted by superprash2003 View Post
    . press CTRL+X and then press Y ( to save changes ).
    sry to trouble you again bro .............
    i wasn't able to understand this line as such as soon i typed the line as mentioned by you then i pressed CTRL+X and there it was shown as ^w in the cron tab and then i pressed y ........... but the line didn't get saved ............
    so bro am i doing it the wrong way kindly help ............
    and yeah the first time i had called the cron tab program it had showed me 3 options something listed like where do you want to save the content (i don't remember exactly) so i had selected the 3rd option .............
    but while i type this command i get to the crontab and at the top of it :-

    # m h dom mon dow command

    this line is their then i delete this line and enter the enteries and at the bottom of it another line is their :-

    "/tmp/crontab.8pfjeB/crontab" 1L, 29C (but this line is not deleteable )

    i'm really confused as to what these two lines refer to ............

  15. #15
    Platinum Member
    Join Date
    Feb 2008
    Liked
    0 times
    Posts
    2,766

    Default

    i've made a detailed tutorial on this here Prashanth Speaks-Technology and Life: How To Reboot Your Router Automatically In Ubuntu (Linux) . . There is a screenshoot to show you how the cron file looks and what you should expect to see when you press CTRL+X . hope it helps..

  16. #16
    Silver Member
    Join Date
    Apr 2008
    Age
    25
    Liked
    0 times
    Posts
    418

    Smile

    Quote Originally Posted by superprash2003 View Post
    i've made a detailed tutorial on this here Prashanth Speaks-Technology and Life: How To Reboot Your Router Automatically In Ubuntu (Linux) . . There is a screenshoot to show you how the cron file looks and what you should expect to see when you press CTRL+X . hope it helps..
    thnxxx a lot bro ..............
    actually infact after trying a lot i got it working but to this i would like to add that now both Kubuntu and Ubuntu (linux) offer GUI support for scheduling tasks ..............
    Kubuntu(8.10) offers inbuilt Task scheduler which can be found under the below listed section :-
    System settings>Advanced>task scheduler

    while in the case of Ubuntu there is another one known as Gnome - scheduler which could be installed via synaptic package manager etc. ........... which offers GUI interface ......

    and yeah thnxx a lot again bro for the script ..........

    but i found another script :-

    #!/usr/bin/env expect

    set username admin
    set pass admin
    set host 192.168.1.1

    spawn telnet ${host}

    expect -re "login:"
    send "${username}\r"

    expect "Password:"
    send "${pass}\r"

    expect -re "#"
    send "kill 1\r"
    send "exit\r"
    expect eof

    this script is posted in a Blog by madhusudancs and with the help by Aditya Kavoor
    the link to the script page is as given below:-

    Restarting your modem/router automatically | Madhusudan.C.S


    the above script seems non-complicated and has lesser no. of lines .......... but works the same ..........
    the script makers can be reached at there Blog's at the below mentioned URL's ..............


    madhusudancs's blog | Madhusudan.C.S

    Aditya Kavoor’s Blog

    The script needs to be modified a bit for different modem types ...........

    Hopefully this would make things more clear ..................

    thnxx everyone for your inputs ............
    Last edited by eruptionjoojo; 04-02-09 at 02:29 PM.

  17. #17
    Platinum Member
    Join Date
    Feb 2008
    Liked
    0 times
    Posts
    2,766

    Default

    oh well. there are many solutions.. glad you got it to work..

  18. #18
    Silver Member
    Join Date
    Dec 2008
    Liked
    0 times
    Posts
    370

    Default

    @eruptionjoojo
    It is again a cron job. Only the script is different (understandable by expect) and executed by expect.

    You have to get some telnet script so that the same can be executed directly from cron. Sorry I am not having any as I never tried. You can google and get some for your modem. As I suggested in my previous post you can directly type the commands in the webmin browser interface.

  19. #19
    Silver Member
    Join Date
    Apr 2008
    Age
    25
    Liked
    0 times
    Posts
    418

    Smile

    Quote Originally Posted by superprash2003 View Post
    oh well. there are many solutions.. glad you got it to work..
    thnxx again bro for your fruitful & promptful responsive replies .............

    Quote Originally Posted by matrix View Post
    @eruptionjoojo
    It is again a cron job. Only the script is different (understandable by expect) and executed by expect.

    You have to get some telnet script so that the same can be executed directly from cron. Sorry I am not having any as I never tried. You can google and get some for your modem. As I suggested in my previous post you can directly type the commands in the webmin browser interface.
    yeah it is cron job infact now i have got it working thnxx for your inputs ..........
    Last edited by eruptionjoojo; 04-02-09 at 10:32 PM. Reason: Automerged Doublepost

  20. #20
    Silver Member
    Join Date
    Dec 2008
    Liked
    0 times
    Posts
    370

    Smile

    Quote Originally Posted by eruptionjoojo View Post
    thnxx again bro for your fruitful & promptful responsive replies .............



    yeah it is cron job infact now i have got it working thnxx for your inputs ..........
    Congrats! Thanks superprash2003 for helping him tirelessly

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Beginner's Guide - Modem selection and troubleshoot
    By meetdilip in forum BSNL broadband
    Replies: 5
    Last Post: 04-24-11, 08:57 PM
  2. Not acquiring IP address, cannot access modem page
    By Outlander in forum BSNL broadband
    Replies: 12
    Last Post: 02-17-10, 09:56 PM
  3. 3rd party modem
    By meetdilip in forum BSNL broadband
    Replies: 6
    Last Post: 02-16-10, 10:19 PM
  4. IPOD TOUCH 2g ON BSNL WIFI type 2 modem
    By ankit in forum BSNL broadband
    Replies: 9
    Last Post: 02-13-10, 12:27 AM
  5. New Modem, No DSL Light
    By Standard1 in forum BSNL broadband
    Replies: 1
    Last Post: 02-06-10, 11:22 PM