Adding Mobile Broadband connection with script?

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
janivee
Level 1
Level 1
Posts: 14
Joined: Tue Aug 30, 2016 11:27 am

Adding Mobile Broadband connection with script?

Post by janivee » Fri Aug 09, 2019 1:14 pm

I have a laptop with Windows and I need to run Linux from USB (not allowed to install it to SSD),
I also have SIM-card for internet connection.

I can get all that running by doing this:

Network Connections
Add a new connection
Mobile Broadband .. Create
Create a connection for this mobile broadband device: "cdc-wdm1" (Lenovo Thinkpad X270)
Choose a country
Enter provider manually (mine is not listed in Mint 19.2)
Enter APN (Access Point Name; you get this from you internet provider)
Give PIN, if asked (you get this from your internet provider)

I would like to make a script which would do all that "automatically", instead of doing that every time from GUI.

Can you help on this matter?

User avatar
absque fenestris
Level 6
Level 6
Posts: 1134
Joined: Sat Nov 12, 2016 8:42 pm
Location: Confoederatio Helvetica

Re: Adding Mobile Broadband connection with script?

Post by absque fenestris » Fri Aug 09, 2019 2:23 pm

janivee wrote:
Fri Aug 09, 2019 1:14 pm
I have a laptop with Windows and I need to run Linux from USB (not allowed to install it to SSD),
I also have SIM-card for internet connection.

I can get all that running by doing this:

Network Connections
Add a new connection
Mobile Broadband .. Create
Create a connection for this mobile broadband device: "cdc-wdm1" (Lenovo Thinkpad X270)
Choose a country
Enter provider manually (mine is not listed in Mint 19.2)
Enter APN (Access Point Name; you get this from you internet provider)
Give PIN, if asked (you get this from your internet provider)

I would like to make a script which would do all that "automatically", instead of doing that every time from GUI.

Can you help on this matter?
Is this a Android phone? If Android - you must create a WEP2 login, in the Android phone - with a strong password. In iOS it's more or less the same...

There is no need for a script... :mrgreen:
Linux Mint 18.3 Sylvia (Mate) 32-bit - Acer D250 Netbook (Intel Atom N270, 2 GB RAM, 120 GB SSD)
Linux Mint 17.3 Rosa (Mate) 64-bit - MacBook Pro 15" (Intel Core2 Duo, 8 GB RAM, 240 GB SSD) - with some separation difficulties...

User avatar
AndyMH
Level 8
Level 8
Posts: 2393
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Adding Mobile Broadband connection with script?

Post by AndyMH » Fri Aug 09, 2019 2:36 pm

Is this a Android phone?
NO if it is anything like my T430, it has a slot for a SIM to give you mobile broadband when all else fails. Literally just done it half an hour ago and as stated in the original post had to set up a new connection (in spite of me doing exactly the same this time last year - upgrade 18.3 to 19.0??). It's the only way I can get internet access on holiday. So... if you could do it via a script I'd be interested.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate

User avatar
absque fenestris
Level 6
Level 6
Posts: 1134
Joined: Sat Nov 12, 2016 8:42 pm
Location: Confoederatio Helvetica

Re: Adding Mobile Broadband connection with script?

Post by absque fenestris » Fri Aug 09, 2019 2:46 pm

AndyMH wrote:
Fri Aug 09, 2019 2:36 pm
Is this a Android phone?
NO if it is anything like my T430, it has a slot for a SIM to give you mobile broadband when all else fails. Literally just done it half an hour ago and as stated in the original post had to set up a new connection (in spite of me doing exactly the same this time last year - upgrade 18.3 to 19.0??). It's the only way I can get internet access on holiday. So... if you could do it via a script I'd be interested.

If I understand correctly: I could insert my SIM card into the appropriate slot - and I turned my laptop into a phone?
Linux Mint 18.3 Sylvia (Mate) 32-bit - Acer D250 Netbook (Intel Atom N270, 2 GB RAM, 120 GB SSD)
Linux Mint 17.3 Rosa (Mate) 64-bit - MacBook Pro 15" (Intel Core2 Duo, 8 GB RAM, 240 GB SSD) - with some separation difficulties...

janivee
Level 1
Level 1
Posts: 14
Joined: Tue Aug 30, 2016 11:27 am

Re: Adding Mobile Broadband connection with script?

Post by janivee » Sat Aug 10, 2019 2:22 am

There is a slot in the laptop where I can put a SIM-card and if laptop can't find Wifi, it will use that SIM-card to connect to internet.
This works very well, i am very happy how Mint does it with X270.

I just would like to know how to write a script, which would do the setup "automatically" by running it, instead of doing it manually every time I boot from USB.

Laptop is company laptop with encryption, so I really can't use its SSD.

janivee
Level 1
Level 1
Posts: 14
Joined: Tue Aug 30, 2016 11:27 am

Re: Adding Mobile Broadband connection with script?

Post by janivee » Sun Aug 18, 2019 5:03 am

If I type these at terminal, I will get SIM connection as I want:

sudo nmcli connection edit type gsm con-name "name for connection"
set gsm.apn apn.data.address.from.provider
set gsm.pin pinfromprovider
save
yes
q

I just don't know, how to run a script from those, which would do all that automatically.

For a wifi connection, I made a script like this (which works for my hidden home wifi):

sudo pkill wpa_supplicant
sudo wpa_supplicant -B -i wlp3s0 -c wpa_supplicant.conf
sudo dhclient wlp3s0

Obviously I have made a "wpa_supplicant.conf" file.

User avatar
AndyMH
Level 8
Level 8
Posts: 2393
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Adding Mobile Broadband connection with script?

Post by AndyMH » Sun Aug 18, 2019 6:41 am

Me - I've switched off wifi and switched on mobile broadband, it shows EE and a connection I created 'EE connection 1'. Each time I boot I have to select 'EE connection 1' to connect. Minor inconvenience but it works. A script would be nice. Main problem (I'm on holiday) is weak mobile signal and hence slow connection speed, but at least it works when all else fails.

Screen shot shows me using my mobile phone as a hotspot - today it has a better signal than the SIM in the laptop:
Workspace 1_023.png
Workspace 1_023.png (70.39 KiB) Viewed 57 times
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate

Post Reply

Return to “Newbie Questions”