tuya-ipc-terminal/tuya_auth_login.exp aktualisiert
This commit is contained in:
parent
1c69804531
commit
06b14e7dd9
@ -1,66 +1,57 @@
|
||||
#!/usr/bin/expect -f
|
||||
|
||||
# --- START SUPER-DEBUG ---
|
||||
# Aktiviere das interne Debugging von Expect. Dies erzeugt SEHR viel Output.
|
||||
# Aktiviere internes Debugging, um den Ablauf zu verfolgen
|
||||
exp_internal 1
|
||||
puts "DEBUG: Expect-Skript gestartet. Internes Debugging ist aktiviert."
|
||||
# --- ENDE SUPER-DEBUG ---
|
||||
puts "DEBUG: Expect-Skript gestartet."
|
||||
|
||||
# Entferne den alten Konfigurationsordner, um eine Neu-Authentifizierung zu erzwingen.
|
||||
# Entferne alte Konfiguration, um eine neue Sitzung zu erzwingen
|
||||
set config_dir "/config/.tuya-data"
|
||||
puts "DEBUG: Prüfe auf Verzeichnis: $config_dir"
|
||||
if { [file isdirectory $config_dir] } {
|
||||
puts "DEBUG: Altes Konfigurationsverzeichnis gefunden. Wird entfernt."
|
||||
puts "DEBUG: Altes Konfigurationsverzeichnis gefunden, wird entfernt."
|
||||
if {[catch {file delete -force -- $config_dir} err]} {
|
||||
puts stderr "FATAL: Konnte existierendes Verzeichnis '$config_dir' nicht löschen: $err"
|
||||
puts stderr "FATAL: Konnte Verzeichnis '$config_dir' nicht löschen: $err"
|
||||
exit 1
|
||||
}
|
||||
puts "DEBUG: Verzeichnis erfolgreich entfernt."
|
||||
} else {
|
||||
puts "DEBUG: Kein altes Konfigurationsverzeichnis gefunden. Fortfahren."
|
||||
}
|
||||
|
||||
puts "DEBUG: Starte den Authentifizierungsprozess..."
|
||||
puts "DEBUG: Starte Authentifizierungsprozess."
|
||||
set timeout 60
|
||||
|
||||
# Lese die Eingaben
|
||||
puts "DEBUG: Lese Region von stdin..."
|
||||
# Lese Eingaben
|
||||
gets stdin region
|
||||
puts "DEBUG: Region gelesen: $region"
|
||||
|
||||
puts "DEBUG: Lese Email von stdin..."
|
||||
gets stdin email
|
||||
puts "DEBUG: Email gelesen: $email"
|
||||
|
||||
puts "DEBUG: Lese Passwort von stdin..."
|
||||
gets stdin password
|
||||
# Das Passwort selbst nicht loggen
|
||||
puts "DEBUG: Passwort wurde gelesen."
|
||||
|
||||
if { $region eq "" || $email eq "" || $password eq "" } {
|
||||
puts stderr "FATAL: Eine der Eingaben (Region, Email, Passwort) ist leer."
|
||||
puts stderr "FATAL: Eine der Eingaben ist leer."
|
||||
exit 1
|
||||
}
|
||||
|
||||
puts "DEBUG: Starte 'spawn tuya-ipc-terminal auth add ...'"
|
||||
spawn tuya-ipc-terminal auth add $region $email --password
|
||||
|
||||
# Interaktion
|
||||
# --- START DER ENTSCHEIDENDEN KORREKTUR ---
|
||||
# Verwende einen regulären Ausdruck (-re), der auf verschiedene Passwortabfragen reagiert.
|
||||
# "Enter ?[Pp]assword:" fängt "Enter password:" und "Enter Password:" ab.
|
||||
expect {
|
||||
"Password:" {
|
||||
puts "DEBUG: 'Password:' Prompt erkannt. Sende Passwort..."
|
||||
-re {Password:|Enter ?[Pp]assword:?|Please enter your password:} {
|
||||
puts "DEBUG: Passwortabfrage erkannt. Sende Passwort..."
|
||||
send "$password\r"
|
||||
puts "DEBUG: Passwort gesendet."
|
||||
# exp_continue sorgt dafür, dass das Skript auf weitere Ausgaben wartet
|
||||
exp_continue
|
||||
}
|
||||
# --- ENDE DER KORREKTUR ---
|
||||
|
||||
"Authentication successful" {
|
||||
puts "DEBUG: Erfolg-Nachricht 'Authentication successful' erkannt."
|
||||
puts "DEBUG: Erfolgsmeldung 'Authentication successful' erkannt."
|
||||
# Warte, bis der Prozess sich beendet hat
|
||||
catch {expect eof}
|
||||
catch {wait}
|
||||
exit 0
|
||||
}
|
||||
eof {
|
||||
puts "DEBUG: 'eof' (End of File) vom Prozess erreicht."
|
||||
puts "DEBUG: Prozess hat sich beendet (EOF)."
|
||||
# Prüfe den Exit-Code des beendeten Prozesses
|
||||
set exit_code [lindex [wait] 2]
|
||||
puts "DEBUG: Prozess beendet mit Exit-Code $exit_code."
|
||||
exit $exit_code
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user