get pppd exit code - how?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I'm designing some reporting system on Raspberry Pi system which connects to world thru 3G usb modem controlled by pppd
.
99,999% of time connection works ok, but sometimes it drops and further reconnect attempts fail unless modem is re-plugged physically.
As in production box will work remotely with no physical access to it so I have to manage it somehow.
My idea is to run at system start, some kind of script in separate thread see below pseudocode:
while(true)
wait_for_modem_device_to_appear
start_pppd # may_be limiting retries not to default 10, but to, say, 3
wait_for_pppd_to_finish
if(exitcode_is_one_of(6,7,8,10,15,16))
reset_usb_port_programmatically #I have tools for that
else
break
- How can I get
pppd
exit code? - Should I use another approach (which)?
shell-script pppd connectivity exit-code
add a comment |Â
up vote
1
down vote
favorite
I'm designing some reporting system on Raspberry Pi system which connects to world thru 3G usb modem controlled by pppd
.
99,999% of time connection works ok, but sometimes it drops and further reconnect attempts fail unless modem is re-plugged physically.
As in production box will work remotely with no physical access to it so I have to manage it somehow.
My idea is to run at system start, some kind of script in separate thread see below pseudocode:
while(true)
wait_for_modem_device_to_appear
start_pppd # may_be limiting retries not to default 10, but to, say, 3
wait_for_pppd_to_finish
if(exitcode_is_one_of(6,7,8,10,15,16))
reset_usb_port_programmatically #I have tools for that
else
break
- How can I get
pppd
exit code? - Should I use another approach (which)?
shell-script pppd connectivity exit-code
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm designing some reporting system on Raspberry Pi system which connects to world thru 3G usb modem controlled by pppd
.
99,999% of time connection works ok, but sometimes it drops and further reconnect attempts fail unless modem is re-plugged physically.
As in production box will work remotely with no physical access to it so I have to manage it somehow.
My idea is to run at system start, some kind of script in separate thread see below pseudocode:
while(true)
wait_for_modem_device_to_appear
start_pppd # may_be limiting retries not to default 10, but to, say, 3
wait_for_pppd_to_finish
if(exitcode_is_one_of(6,7,8,10,15,16))
reset_usb_port_programmatically #I have tools for that
else
break
- How can I get
pppd
exit code? - Should I use another approach (which)?
shell-script pppd connectivity exit-code
I'm designing some reporting system on Raspberry Pi system which connects to world thru 3G usb modem controlled by pppd
.
99,999% of time connection works ok, but sometimes it drops and further reconnect attempts fail unless modem is re-plugged physically.
As in production box will work remotely with no physical access to it so I have to manage it somehow.
My idea is to run at system start, some kind of script in separate thread see below pseudocode:
while(true)
wait_for_modem_device_to_appear
start_pppd # may_be limiting retries not to default 10, but to, say, 3
wait_for_pppd_to_finish
if(exitcode_is_one_of(6,7,8,10,15,16))
reset_usb_port_programmatically #I have tools for that
else
break
- How can I get
pppd
exit code? - Should I use another approach (which)?
shell-script pppd connectivity exit-code
edited Mar 6 at 14:38
asked Mar 6 at 14:09
DmitryD
63
63
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
After calling 'pppd' you need get value of variable '$?'.
$?
- get exit code of last program.
For background processes '$!' may be useful with some cover.
$!
- get PID of last background process that was executed.
Example scenario:
run_background_process &
pid_of_background_process=$!
wait $pid_of_background_process
echo "Result code of background process: "$?
Yury, ppd is running on background so you will get 0 always
â DmitryD
Mar 6 at 14:18
@DmitryD, I've supplemented answer.
â Yurij Goncharuk
Mar 6 at 14:39
Solution you proposed doesn't work even with supplement, but thanks for your try!
â DmitryD
Mar 14 at 17:05
add a comment |Â
up vote
0
down vote
accepted
Bingo!
Put 'nodetach' as command-line argument to pppd and daemon will not fork itself. All is needed then is standard 'echo $?' in next line of script:
pppd call my_provider nodetach maxfail 3
echo $?
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
After calling 'pppd' you need get value of variable '$?'.
$?
- get exit code of last program.
For background processes '$!' may be useful with some cover.
$!
- get PID of last background process that was executed.
Example scenario:
run_background_process &
pid_of_background_process=$!
wait $pid_of_background_process
echo "Result code of background process: "$?
Yury, ppd is running on background so you will get 0 always
â DmitryD
Mar 6 at 14:18
@DmitryD, I've supplemented answer.
â Yurij Goncharuk
Mar 6 at 14:39
Solution you proposed doesn't work even with supplement, but thanks for your try!
â DmitryD
Mar 14 at 17:05
add a comment |Â
up vote
0
down vote
After calling 'pppd' you need get value of variable '$?'.
$?
- get exit code of last program.
For background processes '$!' may be useful with some cover.
$!
- get PID of last background process that was executed.
Example scenario:
run_background_process &
pid_of_background_process=$!
wait $pid_of_background_process
echo "Result code of background process: "$?
Yury, ppd is running on background so you will get 0 always
â DmitryD
Mar 6 at 14:18
@DmitryD, I've supplemented answer.
â Yurij Goncharuk
Mar 6 at 14:39
Solution you proposed doesn't work even with supplement, but thanks for your try!
â DmitryD
Mar 14 at 17:05
add a comment |Â
up vote
0
down vote
up vote
0
down vote
After calling 'pppd' you need get value of variable '$?'.
$?
- get exit code of last program.
For background processes '$!' may be useful with some cover.
$!
- get PID of last background process that was executed.
Example scenario:
run_background_process &
pid_of_background_process=$!
wait $pid_of_background_process
echo "Result code of background process: "$?
After calling 'pppd' you need get value of variable '$?'.
$?
- get exit code of last program.
For background processes '$!' may be useful with some cover.
$!
- get PID of last background process that was executed.
Example scenario:
run_background_process &
pid_of_background_process=$!
wait $pid_of_background_process
echo "Result code of background process: "$?
edited Mar 6 at 14:38
answered Mar 6 at 14:13
Yurij Goncharuk
2,2582521
2,2582521
Yury, ppd is running on background so you will get 0 always
â DmitryD
Mar 6 at 14:18
@DmitryD, I've supplemented answer.
â Yurij Goncharuk
Mar 6 at 14:39
Solution you proposed doesn't work even with supplement, but thanks for your try!
â DmitryD
Mar 14 at 17:05
add a comment |Â
Yury, ppd is running on background so you will get 0 always
â DmitryD
Mar 6 at 14:18
@DmitryD, I've supplemented answer.
â Yurij Goncharuk
Mar 6 at 14:39
Solution you proposed doesn't work even with supplement, but thanks for your try!
â DmitryD
Mar 14 at 17:05
Yury, ppd is running on background so you will get 0 always
â DmitryD
Mar 6 at 14:18
Yury, ppd is running on background so you will get 0 always
â DmitryD
Mar 6 at 14:18
@DmitryD, I've supplemented answer.
â Yurij Goncharuk
Mar 6 at 14:39
@DmitryD, I've supplemented answer.
â Yurij Goncharuk
Mar 6 at 14:39
Solution you proposed doesn't work even with supplement, but thanks for your try!
â DmitryD
Mar 14 at 17:05
Solution you proposed doesn't work even with supplement, but thanks for your try!
â DmitryD
Mar 14 at 17:05
add a comment |Â
up vote
0
down vote
accepted
Bingo!
Put 'nodetach' as command-line argument to pppd and daemon will not fork itself. All is needed then is standard 'echo $?' in next line of script:
pppd call my_provider nodetach maxfail 3
echo $?
add a comment |Â
up vote
0
down vote
accepted
Bingo!
Put 'nodetach' as command-line argument to pppd and daemon will not fork itself. All is needed then is standard 'echo $?' in next line of script:
pppd call my_provider nodetach maxfail 3
echo $?
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Bingo!
Put 'nodetach' as command-line argument to pppd and daemon will not fork itself. All is needed then is standard 'echo $?' in next line of script:
pppd call my_provider nodetach maxfail 3
echo $?
Bingo!
Put 'nodetach' as command-line argument to pppd and daemon will not fork itself. All is needed then is standard 'echo $?' in next line of script:
pppd call my_provider nodetach maxfail 3
echo $?
answered Mar 14 at 17:05
DmitryD
63
63
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f428518%2fget-pppd-exit-code-how%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password