LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   O2 HSPA mobile broadband auto connect using script over ssh (http://www.linuxquestions.org/questions/linux-networking-3/o2-hspa-mobile-broadband-auto-connect-using-script-over-ssh-832822/)

linuxmandrake 09-17-2010 09:26 AM

O2 HSPA mobile broadband auto connect using script over ssh
 
Hi
I;'m wondering how can I get it to automatically connect as soon as it detects the modem. It uses modem manager to connect. I use Gnome network manager applet to connect to o2. However I would rather it run in the background. The pc hosting this connect doesn't have a monitor and so am relying on SSH. Since ssh sessions can't be kept alive it disconnects when the session is closed. I'm too cheap to buy another monitor.

smoker 09-18-2010 05:12 AM

Quote:

Originally Posted by linuxmandrake (Post 4100654)
Since ssh sessions can't be kept alive it disconnects when the session is closed.

Use screen and then the session won't be disconnected.

JZL240I-U 09-22-2010 01:44 AM

In Networkmanager you have the choice to activate automatic connection.

linuxmandrake 09-22-2010 10:34 AM

Yes but the connection doesn't stay on when I close the applet. Is there a way the network manager daemon can automatically connect for me. I.e. similar to what it does for Ethernet wired connections.

JZL240I-U 09-22-2010 11:20 AM

Huh? :scratch: Networkmanager is a daemon AFAIK, it can run detached in the background.

joenew 09-22-2010 11:43 AM

Mmmm, why don't create a "daemon-script', or create a simple script and run it in a screen session?
I'm using pppd scripts to connect ("pppd call mobile" for example is the comand I launch).
I writen a chat script and put it in /etc/ppp, for example /etc/ppp/mobile.chat
Then is needed a pppd script in /etc/ppp/peers.

Code:

$ cat /etc/ppp/peers/mobile
/dev/rfcomm0 9600
connect '/usr/sbin/chat -v -f /etc/ppp/mobile.chat'
noauth
novj
novjccomp
mru 1500
mtu 1500
debug
defaultroute

$ cat /etc/ppp/gprs.chat
'' \d
'' 'atz'
OK 'at+cgatt=1'
OK 'at+cgdcont=1,"IP","your.apn.there"'
OK 'atd*99***1#'

Ok, that's all, "chmod +x" to thoose scripts and launch pppd call mobile as root to connect.
But you want a script that lanch connection command:

Code:

#!/bin/sh
while [ 1 ]
do
  if lsusb |grep $product_key_of_your_modem"
  then
    pppd call mobile
  fi
  sleep 5
done

This is a very simple and bugged example.
You could decide to simply check if connection is up or not and eventually connect.
I'm running a script like that to automatically keep my system online through a bluetooth cellular modem.
I just control if ppp0 interface is up or not and if not connect even if my modem is not in the BT range. In tath case connection just doesn't happens and it just sleep 5 seconds before redo a check.

It's quite simple and you don't need any X server running nor gnome or kde and so on.

linuxmandrake 09-22-2010 05:17 PM

THANKS ALOT U THE MAN. It's works like a charm. Now I'll be battling with udev to get the modem to stop disappearing.


All times are GMT -5. The time now is 07:26 AM.