Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using 10.04 Server.

I have a 3G wireless card, use the switch program which i get from the manufacturer, i can change the 3G card from USB storage mode to 3G modem mode, then following devices are created in /dev :ttyUSB0,ttyUSB1,ttyUSB2.

But I don't know which device to should choose to use 3G, so i have to run wvdialconfig to scan all the possible port and find the proper one. Is there a way to automatically detect the 3G port without using wvdialconfig to scan all the port every time?

share|improve this question
    
Answered in: askubuntu.com/questions/78164/… –  Stuart Jan 4 '12 at 17:57
    
@Stuart I know how to use 3G modem but i just wanna find a automatically way to establish a connection using 3G modem. I mean after switching the 3G modem from a usb storage device to a modem, you have to use wvdialconf EVERY TIME because there are THREE ttyUSB devices(ttyUSB0,ttyUSB1,ttyUSB2) in /dev after switching, after using wvdialconf, this time i may use ttyUSB0 to dial, next time may be ttyUSB1. It's uncertain that i have to use wvdialconf every time after switch. Do you get it? –  HexForFun Jan 4 '12 at 18:27
    
use usb_modeswitch: draisberghof.de/usb_modeswitch after installation it will automatically convert your modem from usb to modem mode. Goto Network connection->mobileBroadband, edit your connection and check for "connect automatically". So when you will start ubuntu usb_modeswitch switch your modem and network-manager automatically connect you with internet. –  shantanu Jan 4 '12 at 19:17
    
@shantanu Do you mean use network-manager applet to set connect automatically to achieve that? i think it should be work,but my working environment is a pure command line interface and no graphic desktop installed, so i choose wvdial for connecting. Is there a way in CLI? –  HexForFun Jan 4 '12 at 19:28
    
can you just post the commands what you give in command line after load your modem in /dev/ttyUSB*. (wvconfig) –  shantanu Jan 4 '12 at 19:40

2 Answers 2

If you connect with network manager, it will work out which one to use. (You can drive it from the command line with nmcli)

share|improve this answer
    
There is not such command nmcli. –  HexForFun Jan 6 '12 at 14:40
    
@HexForFun: It only appeared in maverick –  tumbleweed Jan 6 '12 at 15:05
    
I use 10.04(server version). Can you give a common way to do that? –  HexForFun Jan 6 '12 at 15:15
    
Sorry, there were no command line clients for NM in 10.04. You can drive it by the DBus API, but that's harder. –  tumbleweed Jan 6 '12 at 17:30
    
Can you give me an example?? –  HexForFun Jan 7 '12 at 1:06

Suppose your wvconf file is like this:

[Dialer Defaults]
Modem = /dev/ttyUSB1
Baud = 960800                      //Connection speed
Init = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ISDN = 0
Modem Type = USB Modem
Phone = #777                       // Dialling number
Username = jimstech                // username
Password = jimstech                // password
stupid mode = 1                    // setting as true

Your need to replace the line and test : Modem = /dev/ttyUSB1

again suppose your possible devices are : ttyUSB0 ttyUSB1 ttyUSB2 now we need to replace the line (/dev/ttyUSB1) with ttyUSB0 then run test using wvconf then USB2 then USB3.(I hope) To automate the process use this script

#!/bin/bash
#your commands to load device file
array=(ttyUSB0 ttyUSB1 ttyUSB2 ttyUSB3)
len=${#array[*]} #Number of elements of the array

i=0
while [ $i -lt $len ]; do
rep="Modem = /dev/"${array[$i]}
sed 's*Modem = /dev/tty[A-Z]\*[0-9]*'"$rep"' *'  /etc/wvdial.conf
wvdialconf #break with appropriate behavior
sleep 1
let i++
done
wvdial

I don't have wvdial installed so i don't know what will happen if wvdialconf accept the device. This script must need to run with root permission.

share|improve this answer
    
Thanks for your reply。actually,after run the wvdialconf ,the right device is already written into the wvdialconf.conf. –  HexForFun Jan 5 '12 at 1:35
    
what happen if you run this bash file? change the tty. list in code as you want. –  shantanu Jan 9 '12 at 5:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.