Finished ssh_terminfo
This commit is contained in:
parent
8d37cab8d8
commit
1531dc3b28
@ -1,19 +1,31 @@
|
|||||||
#!/bin/python
|
#!/bin/python
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
path = os.path.expanduser('~') + "/.ssh/config"
|
ssh_config = os.path.expanduser('~') + "/.ssh/config"
|
||||||
|
|
||||||
f = open(path,"r")
|
with open(ssh_config) as file:
|
||||||
lines = f.readlines()
|
file_content = list(file)
|
||||||
|
|
||||||
#ping -c 1 -w 1
|
#ping -c 1 -w 1
|
||||||
|
|
||||||
print(lines.count())
|
for l in file_content:
|
||||||
|
|
||||||
for l in lines:
|
|
||||||
if "host " in l:
|
if "host " in l:
|
||||||
|
l_index = file_content.index(l)
|
||||||
|
index = l_index + 1
|
||||||
|
host_ip = file_content[index].split()[1]
|
||||||
|
|
||||||
|
return_value = subprocess.call(["ping", "-c1", "-w1", host_ip], stdout=open(os.devnull, "w"), stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
if return_value == 0:
|
||||||
ssh_host = l.split()[1]
|
ssh_host = l.split()[1]
|
||||||
|
|
||||||
|
print(f"Host {ssh_host} ({host_ip}) is up. Sending terminfo..")
|
||||||
|
|
||||||
command = f"infocmp | ssh {ssh_host} 'tic -x /dev/stdin'"
|
command = f"infocmp | ssh {ssh_host} 'tic -x /dev/stdin'"
|
||||||
print("Sending terminfo to: " + ssh_host)
|
|
||||||
print("Command: " + command)
|
return_value = subprocess.call(command, shell=True, stdout=open(os.devnull, "w"), stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
if return_value == 1:
|
||||||
|
print(f"Could not send terminfo to {ssh_host}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user