Добавил:
omninoy
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Скрипты / fix_dns_search
.pyimport subprocess
import time
VBOX = r"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe"
VM = "ЗиВКС"
def send_sc(sc_list, wait=0.3):
subprocess.run([VBOX, "controlvm", VM, "keyboardputscancode", *sc_list], check=True)
time.sleep(wait)
# Alt+F4 to close current window
send_sc(["38", "3e", "be", "b8"], wait=0.5)
# Ensure layout is EN
send_sc(["38", "2a", "aa", "b8"], wait=0.3)
# Clear terminal line
send_sc(["1d", "2e", "ae", "9d"], wait=0.3)
# Run sudo nmcli
cmd = "echo 1234567890 | sudo -S nmcli con mod 'Проводное соединение 1' ipv4.dns-search 'bea7341.local' && sudo nmcli con up 'Проводное соединение 1'"
subprocess.run([VBOX, "controlvm", VM, "keyboardputstring", cmd], check=True)
time.sleep(0.05)
send_sc(["1c", "9c"], wait=2.5)
# Re-open nm-connection-editor --edit
subprocess.run([VBOX, "controlvm", VM, "keyboardputstring", "nm-connection-editor --edit=364eec48-6e16-3b92-ad19-89471bf59e9e &"], check=True)
time.sleep(0.05)
send_sc(["1c", "9c"], wait=2.5)
# Switch to IPv4 tab (Ctrl+PageDown 4 times)
for _ in range(4):
send_sc(["1d", "e0", "51", "e0", "d1", "9d"], wait=0.3)
time.sleep(1.0)
out_file = r"C:\Users\omni\Desktop\tusur\ЗИвКС\LR6\screenshots_real\1_network_config_dc.png"
subprocess.run([VBOX, "controlvm", VM, "screenshotpng", out_file], check=True)
print("Captured updated 1_network_config_dc.png")
Соседние файлы в папке Скрипты
