how to write and execute a script so kubuntu would connect to internet at boot?


Results 1 to 15 of 15

Thread: how to write and execute a script so kubuntu would connect to internet at boot?

  1. #1
    Join Date
    Nov 2002
    Location
    Mandat of Israel
    Posts
    172

    how to write and execute a script so kubuntu would connect to internet at boot?

    hi,
    i use kubuntu and i want it to login to my internet connection in boot up.
    i connect by typing in a console :

    # sudo internet --connect=<connection-name>
    #password:*******

    and i want kubuntu to desconnect my internet connection when loging off the system

    the command i use for closing my internet connection is:

    #sudo internet --clearcurr
    #password:*************

    so how i write a script or something so the internet connection gets up in boot up and gets down when closing the computer?

    thanks
    _____________________________________

    "We’re talking about aliens here, general.
    All they do, all they think, all their motivations are,
    by definition...
    .... alien. "
    _____________________________________

  2. #2
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    What's this "internet" script? (I assume it's a script, anyway. It's not a standard Linux utility.) What password is it prompting you for?

  3. #3
    Join Date
    Jun 2004
    Location
    Edwardsville, IL USA
    Posts
    146
    I thought Kubuntu already connected to the Internet at boot...? I know it at least synchronizes with the Ubuntu server clock. Or is this something different?
    "If saving money is wrong, I don't wanna be right." -W. Shatner

  4. #4
    Join Date
    Nov 2002
    Location
    Mandat of Israel
    Posts
    172
    bwkaz:
    don't know if it is a script or a program - i believe it is a program.
    I use it to connect to internet because in israel adsl is a kind of nightmare for linux, or at least for me.
    the password that ask for is my user password , i mean it's necessary to be root to use the "internet" program.
    so i gave to the users authorization on the sudoers. so each one can connect using sudo and their own password.

    i don't have problems using it, my problems is that i would prefer for my wife to not have to use command line commands. and better yet, having kubuntu to connect on boot up....

    & so....
    palsyboy
    yes kubuntu does it, kubuntu is amazing lol, but again, israel adsl connections are something , something..., weird i think lol.
    so my kubuntu can't connect on boot or in no other way without that internet command.
    unfortunately i don't know nothing of connections and internet and.. well...

    but thanks anyway.
    _____________________________________

    "We’re talking about aliens here, general.
    All they do, all they think, all their motivations are,
    by definition...
    .... alien. "
    _____________________________________

  5. #5
    Join Date
    Mar 2003
    Location
    Tampa, FL USA
    Posts
    2,193
    First thing, type:
    whereis internet

    then ls -l /path/to/internet

    To bypass the "sudo", you may simply need to add yourself to the group "dialup".


    After that, we can work on a script.

  6. #6
    Join Date
    Nov 2002
    Location
    Mandat of Israel
    Posts
    172
    wow nice command that one!!!!
    i should remember it, u wont believe that i did find file when i needed to find the path to a file
    man already thank u!!!!

    now,
    path:
    internet: /usr/bin/internet /etc/internet.conf /usr/bin/X11/internet

    ls -l /usr/bin/internet
    -rwxr-xr-x 1 root root 252408 2004-06-12 02:03 /usr/bin/internet

    about the password i did add myself and the other user to the dialup and still we need to use sudo, but anyway that doesn't bother so much now, i did add the other user to sudoers with
    username ALL=/usr/bin/internet

    so there's no prob now, i mean, we need to sudo yet, but at least each user can connect and use internet .

    but still i'll like to have the system to connect on boot up if it isn't complicated in extreme.

    thanks anyway, that command is great, i should find a list of all commands lol
    _____________________________________

    "We’re talking about aliens here, general.
    All they do, all they think, all their motivations are,
    by definition...
    .... alien. "
    _____________________________________

  7. #7
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    I'm asking about the password prompt because it's hard to securely give a password to a process that's prompting for it. But if sudo is what's asking for the password, then it's no big deal: if you run this command at boot, you'll already be root (so the sudo part would be removed from the command).

    Basically, you can probably just put the "internet --connect=<connection-name>" command into rc.local (or whatever kubuntu calls it).

  8. #8
    Join Date
    Mar 2004
    Location
    national city
    Posts
    23

    Talking how i did it

    i have a router that signs in or
    signs in when the router gets rebooted. It has done a hell of job for me.
    I am using a linux router by the way, the name of my router is smoothwall.
    It is an opensource linux distro accomadated to serve as a router.
    if you can get your hands on an old computer that will do.
    am running smoothwall on an old p166 with 32 megs of ram.
    am happy has a dog with the results
    Last edited by yellowdog; 11-24-2005 at 12:54 AM.

  9. #9
    Join Date
    Nov 2002
    Location
    Mandat of Israel
    Posts
    172
    bwkaz
    u got me there, i don't know if it's sudo or the process that it's asking for the password, i just need to be root to use it, then sudo...,

    so, to give a try i need to put the process into rc.local?
    or i need to write a script with the command?

    internet --connect=<connection's_name>

    because i don't know how to write scrpts yet...

    yellowdog:
    i have just une box, it has kubuntu brezy (main system) and windows for the 2 or 3 programs that i still need to use.
    the connection is adsl and the modem's "alcatel's speedtouch home"
    somebody once told me that is possible to configure the alcatel to be a router and connect and disconnect automatically but i can't find any site in the net with a howto (i did find forother alcatel modems, but not mine and not with my bizarre connection) ....
    _____________________________________

    "We’re talking about aliens here, general.
    All they do, all they think, all their motivations are,
    by definition...
    .... alien. "
    _____________________________________

  10. #10
    Join Date
    Mar 2003
    Location
    Tampa, FL USA
    Posts
    2,193
    wow nice command that one!!!!
    (it's replies like this keep me coming back here.)
    I couldn't barely understand what you said, but your welcome.


    Now run this:
    sudo chown root:dialout /usr/bin/internet

    Next question:
    Do you want the script to stop when a user logs off, or when the computer is turned off?
    Last edited by Sepero; 11-24-2005 at 08:21 AM.

  11. #11
    Join Date
    Nov 2002
    Location
    Mandat of Israel
    Posts
    172
    Quote Originally Posted by Sepero
    (it's replies like this keep me coming back here.)
    I couldn't barely understand what you said, but your welcome.


    Now run this:
    sudo chown root:dialup /usr/bin/internet

    Next question:
    Do you want the script to stop when a user logs off, or when the computer is turned off?
    you are welcome friend, now, what exactly did you barely understand? I can try and make it in plastiline for you , or a map maybe? lol.

    now getting serious, if i change the group perms that means that anybody in that group can run the process without sudoing? How can it be i didn't think about that one alone???!!!! goDs!!!!

    the script to stop when the user logs off or the computer is turned off.... mmhhh, don't really know. looks like better when the computer is turned off, but maybe are there security issues if the system stay a while in the prompt and connected to the net? (anyway i didn't configure yet my firewall so..)
    mmhh i think when turning off the computer, yeah,.

    edit:
    errr......
    can it be that there isn't no dialup group? i have dialout group
    and i don't know yet how to get info about each group (like what it does. eg: what exactly dialout does? )
    and can i create dialup like i created normal users?
    Last edited by yhotg; 11-24-2005 at 06:33 AM.
    _____________________________________

    "We’re talking about aliens here, general.
    All they do, all they think, all their motivations are,
    by definition...
    .... alien. "
    _____________________________________

  12. #12
    Join Date
    Mar 2003
    Location
    Tampa, FL USA
    Posts
    2,193
    Sorry!
    You are correct, it is "dialout".

    Now that I think about it, shouldn't Kubuntu have the program kppp? Why aren't you using that to dial the internet?

    Anyway, if you still want to go with the script:
    Code:
    #!/bin/bash
    # autointernet.sh - A script to automatically stay connected to the internet.
    
    count=8 # Number of seconds between checking internet connection.
    while true
    do
      # "connected" will equal to "pppX" if connected to the internet.
      connected=`ifconfig -a | grep -e "ppp" | cut -d " " -f 1`
      # If connected is equal to "", then we are NOT connected to the internet and need to connect.
      if [ -z $connected ]
      then
        internet --connect=<connection-name> # Insert connection name here.
      fi
       # Sleep for $count (8) seconds, then check that we are still connected. (loops forever)
      sleep $count
    done
    You can save that as ~/autointernet.sh, and add at the bottom of your ~/.xinitrc file this:
    /home/user/autointernet.sh &

    That script runs infinitely, looping every 8 seconds(you can change that part). If it notices you are offlne, it will immediately try to reconnect you. If you want to ever kill it, just run:
    killall -9 autointernet.sh

    PS.
    Don't forget to set the script as executable:
    chmod 755 autointernet.sh

  13. #13
    Join Date
    Nov 2002
    Location
    Mandat of Israel
    Posts
    172
    i tried many time to configure kppp, problm is that i have ADSL connection and kppp continues asking for a phone number and the modem connection port, and i can't find the modem any where, i mean, i know where it is, lol, over the computer box, connected to the eth0 over the phone plug,
    i'll try later at night that script...., it looks very complicated, (lol, can't find yet a place where to learn bash scripting)

    and i'll search and ask a little again in the kde and kubuntu forum if anybody knows some info about kppp and adsl in israel.

    thanks for now, i'll tell u how it goes with the script....

    _____________________________________

    "We’re talking about aliens here, general.
    All they do, all they think, all their motivations are,
    by definition...
    .... alien. "
    _____________________________________

  14. #14
    Join Date
    Mar 2003
    Location
    Tampa, FL USA
    Posts
    2,193
    The script is really Very simple. If you take out the comments, it's only _10_ lines. When you have a script that is 100 lines or more, THEN is when things start to get complicated.

    Here is a bash scripting resource that will take you from newbie to Pro:
    http://www.tldp.org/LDP/abs/abs-guide.pdf
    http://www.tldp.org/LDP/abs/

  15. #15
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    Quote Originally Posted by yhotg
    u got me there, i don't know if it's sudo or the process that it's asking for the password,
    From your description earlier, it's sudo:

    the password that ask for is my user password , i mean it's necessary to be root to use the "internet" program.
    so i gave to the users authorization on the sudoers. so each one can connect using sudo and their own password.
    I took this to mean that you had configured sudo to allow the appropriate users to run this command, if they gave sudo their password (i.e., not root's password).

    That would mean that sudo is what's asking you for the password here.

    I think Sepero got you started with the rest, at least. Though I'll probably keep reading this thread, just in case.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •