Rewrite on bash: import os pref = '/opt/config/network/interfaces.' real =…
- User
Rewrite on bash:
import os
pref = '/opt/config/network/interfaces.' real = '/etc/network/interfaces' action = ''
while ' '.join(action).strip() != 'exit':
print() available = os.listdir('/opt/config/network') for av in available: av = av.split('.')[1] print('\t' + av) print() action = input('exit, use [name], edit [name], clone [name] [to], remove [name], wifi-scan, ifconfig, test: ') action = action.strip().split(' ') if action[0] == 'use': os.system(f'sudo cp {pref}{action[1]} {real}') os.system('sudo systemctl restart networking') elif action[0] == 'edit': os.system(f'sudo nano {pref}{action[1]}') elif action[0] == 'clone': os.system(f'sudo cp {pref}{action[1]} {pref}{action[2]}') elif action[0] == 'remove': os.system(f'sudo rm {pref}{action[1]}') elif action[0] == 'wifi-scan': os.system('sudo iwlist scanning | egrep "SSID|Freq|WPA|Auth|Signal|level"') elif action[0] == 'ifconfig': os.system('ifconfig') elif action[0] == 'test': os.system('ping -c 4 github.com')os.system(f'sudo cp {pref}loopback-only {real}') os.system('sudo -K')
- Assistant