1

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

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

1 Comment

Gosh, you made this like the simplist to fix. thanks.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.