I need to run these commands as needed. Preferably I'd like to double click the file, and have the commands run, then the file closes.
However, when I run the command via open terminal on ubuntu and type ./start_wifi.py it fails with:
$ ./start_wifi.py
^C./start_wifi.py: line 6: syntax error near unexpected token `"rfkill unblock all"'
./start_wifi.py: line 6: `os.system("rfkill unblock all")'
here is my script:
#!/bin/bash
import os
import time
os.system("rfkill unblock all")
print("\nunblocked wlp5s0\n")
os.system("sudo iwlist wlp5s0 scan")
print("\nscanned for wireless networks\n")
os.system("sudo ip link set wlp5s0 up")
print("\nbrought up wlp5s0...\ngive it 5 seconds...\nsleeping now\n")
time.sleep(5)
exit()
What can I do to achieve this?
asked Nov 11, 2016 at 22:06
Jshee
2,6808 gold badges46 silver badges63 bronze badges
1 Answer 1
The code is in Python but the shebang #!/bin/bash is Bash. Change the first line to this:
#!/usr/bin/env python
answered Nov 11, 2016 at 22:08
janos
126k31 gold badges243 silver badges253 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Jshee
Gosh, you made this like the simplist to fix. thanks.
default