iwconfig unavailable to processes started with crontab @reboot?
up vote
0
down vote
favorite
this is my first post to stackoverflow, so please bear with me :)
I'm trying to read the output of iwconfig from a python script to determine whether there is a wifi connection. When I run script (via a bash script that first sets the directory) using crontab @reboot (user, not root), subprocess.check_output(['iwconfig'])
always throws an [Errno 2]. This is even true when I catch the error using try/except and loop the code, so it is still running when the Wifi is certainly connected (as I can check with running iwconfig manually). When I run the python script from the command line via the same bash script, it works fine. What am I overlooking?
#!/usr/bin/python3
import subprocess
import time
import logging
logging.basicConfig(filename='wifi_check.log', filemode='w', format='%(name)s - %(levelname)s
- %(message)s', level=logging.DEBUG)
logging.info("Checking for Wifi")
for i in range(20):
try:
iwconfig_output = subprocess.check_output(['iwconfig']).decode('utf-8')
except Exception as err:
logging.error(str(i) + str(err))
else:
logging.debug(str(i) + iwconfig_output)
if "ESSID" in iwconfig_output:
logging.info(str(i) + "Wifi active")
time.sleep(10)
python python-3.x cron raspbian iwconfig
add a comment |
up vote
0
down vote
favorite
this is my first post to stackoverflow, so please bear with me :)
I'm trying to read the output of iwconfig from a python script to determine whether there is a wifi connection. When I run script (via a bash script that first sets the directory) using crontab @reboot (user, not root), subprocess.check_output(['iwconfig'])
always throws an [Errno 2]. This is even true when I catch the error using try/except and loop the code, so it is still running when the Wifi is certainly connected (as I can check with running iwconfig manually). When I run the python script from the command line via the same bash script, it works fine. What am I overlooking?
#!/usr/bin/python3
import subprocess
import time
import logging
logging.basicConfig(filename='wifi_check.log', filemode='w', format='%(name)s - %(levelname)s
- %(message)s', level=logging.DEBUG)
logging.info("Checking for Wifi")
for i in range(20):
try:
iwconfig_output = subprocess.check_output(['iwconfig']).decode('utf-8')
except Exception as err:
logging.error(str(i) + str(err))
else:
logging.debug(str(i) + iwconfig_output)
if "ESSID" in iwconfig_output:
logging.info(str(i) + "Wifi active")
time.sleep(10)
python python-3.x cron raspbian iwconfig
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
this is my first post to stackoverflow, so please bear with me :)
I'm trying to read the output of iwconfig from a python script to determine whether there is a wifi connection. When I run script (via a bash script that first sets the directory) using crontab @reboot (user, not root), subprocess.check_output(['iwconfig'])
always throws an [Errno 2]. This is even true when I catch the error using try/except and loop the code, so it is still running when the Wifi is certainly connected (as I can check with running iwconfig manually). When I run the python script from the command line via the same bash script, it works fine. What am I overlooking?
#!/usr/bin/python3
import subprocess
import time
import logging
logging.basicConfig(filename='wifi_check.log', filemode='w', format='%(name)s - %(levelname)s
- %(message)s', level=logging.DEBUG)
logging.info("Checking for Wifi")
for i in range(20):
try:
iwconfig_output = subprocess.check_output(['iwconfig']).decode('utf-8')
except Exception as err:
logging.error(str(i) + str(err))
else:
logging.debug(str(i) + iwconfig_output)
if "ESSID" in iwconfig_output:
logging.info(str(i) + "Wifi active")
time.sleep(10)
python python-3.x cron raspbian iwconfig
this is my first post to stackoverflow, so please bear with me :)
I'm trying to read the output of iwconfig from a python script to determine whether there is a wifi connection. When I run script (via a bash script that first sets the directory) using crontab @reboot (user, not root), subprocess.check_output(['iwconfig'])
always throws an [Errno 2]. This is even true when I catch the error using try/except and loop the code, so it is still running when the Wifi is certainly connected (as I can check with running iwconfig manually). When I run the python script from the command line via the same bash script, it works fine. What am I overlooking?
#!/usr/bin/python3
import subprocess
import time
import logging
logging.basicConfig(filename='wifi_check.log', filemode='w', format='%(name)s - %(levelname)s
- %(message)s', level=logging.DEBUG)
logging.info("Checking for Wifi")
for i in range(20):
try:
iwconfig_output = subprocess.check_output(['iwconfig']).decode('utf-8')
except Exception as err:
logging.error(str(i) + str(err))
else:
logging.debug(str(i) + iwconfig_output)
if "ESSID" in iwconfig_output:
logging.info(str(i) + "Wifi active")
time.sleep(10)
python python-3.x cron raspbian iwconfig
python python-3.x cron raspbian iwconfig
asked Nov 11 at 16:45
Beat
32
32
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Errno 2
can indicate that the file is not found.
Perhaps iwconfig
is not in PATH for the user who executes the script. Try using /sbin/iwconfig
(the full path) of the executable to rule this out.
thanks a lot, that did it! (i had actually tried the full path but got it wrong).
– Beat
Nov 11 at 20:04
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Errno 2
can indicate that the file is not found.
Perhaps iwconfig
is not in PATH for the user who executes the script. Try using /sbin/iwconfig
(the full path) of the executable to rule this out.
thanks a lot, that did it! (i had actually tried the full path but got it wrong).
– Beat
Nov 11 at 20:04
add a comment |
up vote
0
down vote
accepted
Errno 2
can indicate that the file is not found.
Perhaps iwconfig
is not in PATH for the user who executes the script. Try using /sbin/iwconfig
(the full path) of the executable to rule this out.
thanks a lot, that did it! (i had actually tried the full path but got it wrong).
– Beat
Nov 11 at 20:04
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Errno 2
can indicate that the file is not found.
Perhaps iwconfig
is not in PATH for the user who executes the script. Try using /sbin/iwconfig
(the full path) of the executable to rule this out.
Errno 2
can indicate that the file is not found.
Perhaps iwconfig
is not in PATH for the user who executes the script. Try using /sbin/iwconfig
(the full path) of the executable to rule this out.
answered Nov 11 at 16:52
Uku Loskit
29.9k86779
29.9k86779
thanks a lot, that did it! (i had actually tried the full path but got it wrong).
– Beat
Nov 11 at 20:04
add a comment |
thanks a lot, that did it! (i had actually tried the full path but got it wrong).
– Beat
Nov 11 at 20:04
thanks a lot, that did it! (i had actually tried the full path but got it wrong).
– Beat
Nov 11 at 20:04
thanks a lot, that did it! (i had actually tried the full path but got it wrong).
– Beat
Nov 11 at 20:04
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53250930%2fiwconfig-unavailable-to-processes-started-with-crontab-reboot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
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