
Ich versuche zu rennen
WID=`xdotool search "Inbox" | head -1`
xdotool windowactivate $WID
xdotool key Up
jedes Mal stdout von
$ CAMEL_DEBUG=all evolution
ergibt "Startleerlauf".
Ich habe mir dieses Skript ausgedacht, das tut, was ich will, aber nur einmal. Es tut es nicht jedes Mal, wenn „Starting Idle“ angezeigt wird, sondern nur einmal und stoppt dann. Ich kenne Bash nicht gut genug, um es zu zwingen, sich endlos zu wiederholen.
exec 3< <(CAMEL_DEBUG=all evolution)
while read line; do
case "$line" in
*"starting idle"*)
echo "'$line' contains staring idle"
WID=`xdotool search "Inbox" | head -1`
xdotool windowactivate $WID
xdotool key Up
break
;;
*)
echo "'$line' does not contain starting idle."
;;
esac
done <&3
exec 3<&-
Danke.
Antwort1
Der break
Befehl beendet die while
Schleife. Lassen Sie ihn fallen.
Antwort2
Sie könnten es mit etwas Komplexerem versuchen. Leiten Sie zunächst die Ausgabe evolution
in eine Datei um:
CAMEL_DEBUG=all evolution > tmpout
Erstellen Sie dann eine Endlosschleife while
, die die Datei liest und reagiert, wenn eine Zeichenfolge gefunden wird:
#!/usr/bin/env bash
while true; do
while read line; do
case "$line" in
*"starting idle"*)
echo "'$line' contains staring idle"
WID=`xdotool search "Inbox" | head -1`
xdotool windowactivate $WID
xdotool key Up
break
;;
*)
echo "'$line' does not contain starting idle."
;;
esac
done < tmpout
done