Nachtrag zu meinen Eintrag,
anbei der komplett befehl in Pythen Code.
Das stoppen des VNC Server über SSH funktioniert auf der Linux Maschien.
Auch Abrufen "date" pwd geht.
Könnne solch Befehle wie VNC start nicht über SSH ausgefühert werden, gibt es eine andere Möglichkeit?
Code: Alles auswählen
import locale
import tkinter as tk
import tkinter.font as font
from tkinter import messagebox
import time
from paramiko.client import SSHClient, AutoAddPolicy
from sshtunnel import open_tunnel
from scp import SCPClient
import requests
from threading import Timer, Thread, Event
import subprocess
window = tk.Tk()
# setting attribute
#window.attributes('-fullscreen', True)
window.geometry('600x400')
window.resizable(True, True)
window.title("Servicetool")
#Schriftarte defenieren
txtFont = font.Font(family='Helvetica') # Schriftart
txtWeight = font.Font(weight="bold") # Art der Schriftstärke
txtSize25 = font.Font(size=25) # Schriftgröße
txtSize12 = font.Font(size=12) # Schriftgröße
def btnConnectVNCClick():
host = "192.168.178.1"
port = "22"
username = "Admin"
password = "Admin"
commands=["sudo ../etc/init.d/x11vnc start"]
client = SSHClient()
client.set_missing_host_key_policy(AutoAddPolicy())
try:
client.connect(hostname=host, username=username, password=password)
print("Verbindung zu der IP "+str(host))
except:
print("[!] Verbindung nicht möglich")
exit()
# execute the commands
#time.sleep(10)
for command in commands:
print("="*10, command, "="*10)
stdin, stdout, stderr = client.exec_command(command)
print(stdout.read().decode())
err = stderr.read().decode()
if err:
print(err)
def btnCloseClick():
window.destroy()
btnClose = tk.Button(window, text="Schließen",
#width=10,
#height=100,
padx=5,
pady=3,
#image=photoKommen,
bd=2,
#relief="sunken",
#compound="top",
command=btnCloseClick)
btnClose['font'] = txtFont
btnClose['font'] = txtWeight
btnClose['font'] = txtSize12
btnClose.pack()
btnClose.place(x=500, y=350)
btnConnectVNC = tk.Button(window, text="Start VNC",
width=15,
#height=100,
padx=5,
pady=3,
#image=photoKommen,
bd=2,
#relief="sunken",
#compound="top",
command=btnConnectVNCClick)
btnConnectVNC['font'] = txtFont
btnConnectVNC['font'] = txtWeight
btnConnectVNC['font'] = txtSize12
btnConnectVNC.pack()
btnConnectVNC.place(x=50, y=50)
window.mainloop()