run script when modem manager detects modem Unicorn Meta Zoo #1: Why another podcast? ...

Simulate round-robin tournament draw

Like totally amazing interchangeable sister outfit accessory swapping or whatever

What were wait-states, and why was it only an issue for PCs?

When speaking, how do you change your mind mid-sentence?

What's parked in Mil Moscow helicopter plant?

Is it appropriate to mention a relatable company blog post when you're asked about the company?

What's called a person who works as someone who puts products on shelves in stores?

What *exactly* is electrical current, voltage, and resistance?

Why did Europeans not widely domesticate foxes?

France's Public Holidays' Puzzle

Philosophers who were composers?

How was Lagrange appointed professor of mathematics so early?

How would you suggest I follow up with coworkers about our deadline that's today?

Can gravitational waves pass through a black hole?

What does the black goddess statue do and what is it?

Where/What are Arya's scars from?

What happened to Viserion in Season 7?

Are these square matrices always diagonalisable?

In search of the origins of term censor, I hit a dead end stuck with the greek term, to censor, λογοκρίνω

Was there ever a LEGO store in Miami International Airport?

Was Objective-C really a hindrance to Apple software development?

Why does the Cisco show run command not show the full version, while the show version command does?

Is it accepted to use working hours to read general interest books?

Marquee sign letters



run script when modem manager detects modem



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraHow do I get a CDMA USB Modem ZTE AC682 modem working?modem-manager not workingModem Manager crashing in 12.10HSPA 3g modem manager for backtrack/ubuntuModem manager in Ubuntu14.04network manager - run script when connect failed'ip-config-unavailable' error when USB modem tries to connectModem Manager Gui breaks after first timemodem-manager with Quectel EC21Can't make Dell Gateway 5000 with Ubuntu Core 16 as Access Point.





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I need to run a script that will create a connection when modem manager detects a modem (ie. mmcli -L lists the modem). I currently have a udev rule set up to do this, but mmcli takes so long to register the modem that the script has already finished running.



I am hoping there is a way to do one of the following things:




  1. Delay the start of the script from udev

  2. Allow the script to run in the background or go to sleep until mmcli sees the modem (I have been trying to get this to work, but calls to the sleep function are skipped, and it won't let me run in a different thread)

  3. Run script automatically when mmcli recognizes the modem


Here is a snippet of my most recent attempt:



sleep 10
count=0
while [ count < 300 ]
do
index=$(mmcli -L | grep Modem | head -n1 | awk '{print $1;}')
let "count+=1"
done
port=$(mmcli -m $index | grep 'primary port' | grep -oP 'ttyACM[0-9]')
connection=$(nmcli c show | grep "modem${port: -1}")
# check if connection does not exist
if [ ! $connection ]; then
echo 'adding new connection at ' date >> /home/nvidia/runlog.txt
nmcli c add type gsm ifname "${port}" con-name "modem${port: -1}" apn testers.apn.com
fi
nmcli c up "modem${port: -1}"









share|improve this question

























  • How about testing for the modem to show up in the output of mmcli -L inside the script before the connection part? Something like: while :;do mmcli -L|grep -q modem_name&&break;sleep 1;done – Or how about using the -w option to “Monitor the state of a given modem”, one could parse its output and act on that.

    – dessert
    9 hours ago













  • I will try, but up to now nothing in the script has worked. Udev is supposed to be used for short scripts and every time I try to slow the script down it doesn't work. I have put sleep statements in and it just ignores them. I have tried to put really long loops in the code, but it just ignores them, somehow.

    – Austin
    9 hours ago











  • @dessert your suggestion had some success, it didn't skip over the loop. It did have the unexpected consequence of modem manager never recognizing the modem. I think this has to do with the rule never finishing since it waits for the modem to register. Udev may have blocked it from being seen while the script was run, I will be looking more into this.

    – Austin
    9 hours ago


















0















I need to run a script that will create a connection when modem manager detects a modem (ie. mmcli -L lists the modem). I currently have a udev rule set up to do this, but mmcli takes so long to register the modem that the script has already finished running.



I am hoping there is a way to do one of the following things:




  1. Delay the start of the script from udev

  2. Allow the script to run in the background or go to sleep until mmcli sees the modem (I have been trying to get this to work, but calls to the sleep function are skipped, and it won't let me run in a different thread)

  3. Run script automatically when mmcli recognizes the modem


Here is a snippet of my most recent attempt:



sleep 10
count=0
while [ count < 300 ]
do
index=$(mmcli -L | grep Modem | head -n1 | awk '{print $1;}')
let "count+=1"
done
port=$(mmcli -m $index | grep 'primary port' | grep -oP 'ttyACM[0-9]')
connection=$(nmcli c show | grep "modem${port: -1}")
# check if connection does not exist
if [ ! $connection ]; then
echo 'adding new connection at ' date >> /home/nvidia/runlog.txt
nmcli c add type gsm ifname "${port}" con-name "modem${port: -1}" apn testers.apn.com
fi
nmcli c up "modem${port: -1}"









share|improve this question

























  • How about testing for the modem to show up in the output of mmcli -L inside the script before the connection part? Something like: while :;do mmcli -L|grep -q modem_name&&break;sleep 1;done – Or how about using the -w option to “Monitor the state of a given modem”, one could parse its output and act on that.

    – dessert
    9 hours ago













  • I will try, but up to now nothing in the script has worked. Udev is supposed to be used for short scripts and every time I try to slow the script down it doesn't work. I have put sleep statements in and it just ignores them. I have tried to put really long loops in the code, but it just ignores them, somehow.

    – Austin
    9 hours ago











  • @dessert your suggestion had some success, it didn't skip over the loop. It did have the unexpected consequence of modem manager never recognizing the modem. I think this has to do with the rule never finishing since it waits for the modem to register. Udev may have blocked it from being seen while the script was run, I will be looking more into this.

    – Austin
    9 hours ago














0












0








0








I need to run a script that will create a connection when modem manager detects a modem (ie. mmcli -L lists the modem). I currently have a udev rule set up to do this, but mmcli takes so long to register the modem that the script has already finished running.



I am hoping there is a way to do one of the following things:




  1. Delay the start of the script from udev

  2. Allow the script to run in the background or go to sleep until mmcli sees the modem (I have been trying to get this to work, but calls to the sleep function are skipped, and it won't let me run in a different thread)

  3. Run script automatically when mmcli recognizes the modem


Here is a snippet of my most recent attempt:



sleep 10
count=0
while [ count < 300 ]
do
index=$(mmcli -L | grep Modem | head -n1 | awk '{print $1;}')
let "count+=1"
done
port=$(mmcli -m $index | grep 'primary port' | grep -oP 'ttyACM[0-9]')
connection=$(nmcli c show | grep "modem${port: -1}")
# check if connection does not exist
if [ ! $connection ]; then
echo 'adding new connection at ' date >> /home/nvidia/runlog.txt
nmcli c add type gsm ifname "${port}" con-name "modem${port: -1}" apn testers.apn.com
fi
nmcli c up "modem${port: -1}"









share|improve this question
















I need to run a script that will create a connection when modem manager detects a modem (ie. mmcli -L lists the modem). I currently have a udev rule set up to do this, but mmcli takes so long to register the modem that the script has already finished running.



I am hoping there is a way to do one of the following things:




  1. Delay the start of the script from udev

  2. Allow the script to run in the background or go to sleep until mmcli sees the modem (I have been trying to get this to work, but calls to the sleep function are skipped, and it won't let me run in a different thread)

  3. Run script automatically when mmcli recognizes the modem


Here is a snippet of my most recent attempt:



sleep 10
count=0
while [ count < 300 ]
do
index=$(mmcli -L | grep Modem | head -n1 | awk '{print $1;}')
let "count+=1"
done
port=$(mmcli -m $index | grep 'primary port' | grep -oP 'ttyACM[0-9]')
connection=$(nmcli c show | grep "modem${port: -1}")
# check if connection does not exist
if [ ! $connection ]; then
echo 'adding new connection at ' date >> /home/nvidia/runlog.txt
nmcli c add type gsm ifname "${port}" con-name "modem${port: -1}" apn testers.apn.com
fi
nmcli c up "modem${port: -1}"






scripts network-manager udev usb-modem modem-manager






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 8 hours ago









dessert

25.7k674108




25.7k674108










asked 9 hours ago









AustinAustin

13




13













  • How about testing for the modem to show up in the output of mmcli -L inside the script before the connection part? Something like: while :;do mmcli -L|grep -q modem_name&&break;sleep 1;done – Or how about using the -w option to “Monitor the state of a given modem”, one could parse its output and act on that.

    – dessert
    9 hours ago













  • I will try, but up to now nothing in the script has worked. Udev is supposed to be used for short scripts and every time I try to slow the script down it doesn't work. I have put sleep statements in and it just ignores them. I have tried to put really long loops in the code, but it just ignores them, somehow.

    – Austin
    9 hours ago











  • @dessert your suggestion had some success, it didn't skip over the loop. It did have the unexpected consequence of modem manager never recognizing the modem. I think this has to do with the rule never finishing since it waits for the modem to register. Udev may have blocked it from being seen while the script was run, I will be looking more into this.

    – Austin
    9 hours ago



















  • How about testing for the modem to show up in the output of mmcli -L inside the script before the connection part? Something like: while :;do mmcli -L|grep -q modem_name&&break;sleep 1;done – Or how about using the -w option to “Monitor the state of a given modem”, one could parse its output and act on that.

    – dessert
    9 hours ago













  • I will try, but up to now nothing in the script has worked. Udev is supposed to be used for short scripts and every time I try to slow the script down it doesn't work. I have put sleep statements in and it just ignores them. I have tried to put really long loops in the code, but it just ignores them, somehow.

    – Austin
    9 hours ago











  • @dessert your suggestion had some success, it didn't skip over the loop. It did have the unexpected consequence of modem manager never recognizing the modem. I think this has to do with the rule never finishing since it waits for the modem to register. Udev may have blocked it from being seen while the script was run, I will be looking more into this.

    – Austin
    9 hours ago

















How about testing for the modem to show up in the output of mmcli -L inside the script before the connection part? Something like: while :;do mmcli -L|grep -q modem_name&&break;sleep 1;done – Or how about using the -w option to “Monitor the state of a given modem”, one could parse its output and act on that.

– dessert
9 hours ago







How about testing for the modem to show up in the output of mmcli -L inside the script before the connection part? Something like: while :;do mmcli -L|grep -q modem_name&&break;sleep 1;done – Or how about using the -w option to “Monitor the state of a given modem”, one could parse its output and act on that.

– dessert
9 hours ago















I will try, but up to now nothing in the script has worked. Udev is supposed to be used for short scripts and every time I try to slow the script down it doesn't work. I have put sleep statements in and it just ignores them. I have tried to put really long loops in the code, but it just ignores them, somehow.

– Austin
9 hours ago





I will try, but up to now nothing in the script has worked. Udev is supposed to be used for short scripts and every time I try to slow the script down it doesn't work. I have put sleep statements in and it just ignores them. I have tried to put really long loops in the code, but it just ignores them, somehow.

– Austin
9 hours ago













@dessert your suggestion had some success, it didn't skip over the loop. It did have the unexpected consequence of modem manager never recognizing the modem. I think this has to do with the rule never finishing since it waits for the modem to register. Udev may have blocked it from being seen while the script was run, I will be looking more into this.

– Austin
9 hours ago





@dessert your suggestion had some success, it didn't skip over the loop. It did have the unexpected consequence of modem manager never recognizing the modem. I think this has to do with the rule never finishing since it waits for the modem to register. Udev may have blocked it from being seen while the script was run, I will be looking more into this.

– Austin
9 hours ago










0






active

oldest

votes












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1136490%2frun-script-when-modem-manager-detects-modem%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1136490%2frun-script-when-modem-manager-detects-modem%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Why do type traits not work with types in namespace scope?What are POD types in C++?Why can templates only be...

Will tsunami waves travel forever if there was no land?Why do tsunami waves begin with the water flowing away...

Simple Scan not detecting my scanner (Brother DCP-7055W)Brother MFC-L2700DW printer can print, can't...