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?

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
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

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.