How do I write a script to randomly choose a vpn location with NetworkManager?

Mark LaPierre marklapier at aol.com
Sun Feb 10 23:54:25 UTC 2013


On 02/10/2013 05:58 PM, Reindl Harald wrote:
>
>
> Am 10.02.2013 23:56, schrieb T.C. Hollingsworth:
>> On Sun, Feb 10, 2013 at 12:48 PM, Bill Oliver<vendor at billoblog.com>  wrote:
>>> I commonly access the net through a vpn service that has multiple locations
>>> for me to use.  Right now, when I go into KDE with Fedora 18, NetworkManager
>>> automatically gets me on the correct wireless net (if I've set the option),
>>> but I have to access the vpn by opening the network icon in the desktop
>>> panel and clicking on whichever vpn site I want to use.
>>>
>>> I can click on "connect automatically" on any one of the vpn options and it
>>> will connect.  That works fine.
>>>
>>> But... what I want to do is to *randomly* choose one of the options and
>>> connect to it automatically when I boot up.
>>>
>>> I know how to use bash or python or perl to write a script, but I don't know
>>> how to tell it to talk to NetworkManager.
>>>
>>> Anybody know how to do that, or can point me to a tutorial or such?
>>
>> nmcli con up id<connection name>
>>
>> See `nmcli con` for a list of connections and `man nmcli` for more information
>
> but RANDOMLY?
>
> wtf - a computer is not a gambling machine
> what sense makes a RANDOM connection?
>

Use random number generator in your script that generates a random 
number from zero to the number of connections to choose from.

You said that you know how to write script.  Use a case statement, or 
similar, to select the appropriate connection to activate.  Fire off 
this script at boot up to make your connection.  Be sure to schedule the 
script to start up after NM has started.

-- 
     _
    °v°
   /(_)\
    ^ ^  Mark LaPierre
Registered Linux user No #267004
https://linuxcounter.net/
****


More information about the users mailing list