ubuntuusers.de

Anhang: xauth add.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python

import os

def is_in_dic(char, dic):
	i = 0
	while i < len(dic):
		if dic[i] == char:
			return True
		i = i + 1
	return False
def get_part_after_text(source, string):
	i = 0
	found_i = 0
	found = ""
	number = ""
	while i < len(source):
		if source[i] == string[found_i]:
			found = found + source[i]
			found_i = found_i + 1
		else:
			found = ""
			found_i = 0
		if found == string:
			i = i + 1
			# if string was found, get the number behind it
			numbers = {0 : "0", 1 : "1", 2 : "2", 3 : "3", 4 : "4", 5 : "5", 6 : "6", 7 : "7", 8 : "8", 9 : "9", 10 : "a", 11 : "b", 12 : "c", 13 : "d", 14 : "e", 15 : "f"}
			while i < len(source) and is_in_dic(source[i], numbers):
				number = number + source[i]
				i = i + 1
			return number
			break
		i = i + 1
	return False

output = os.popen("xauth -vqibn list").read()

hexid = get_part_after_text(output, "MIT-MAGIC-COOKIE-1  ")

os.popen("xauth -vqibn add :1.0 MIT-MAGIC-COOKIE-1 " + hexid)
Anhang herunterladen

http://download.lima-city.de/pinguinfreund/xauth_add.py

Diese Revision wurde am 10. Februar 2020 18:16 von ubuntuusers erstellt.