ich versuche mir in einem BASH-Skript die aktiven Sessions bestimmter Clients auszulesen.
Code: Alles auswählen
while IFS= read -r clients; do
# Debugging-Ausgabe
# echo "Client: '$clients'"
# echo "Befehl: opsi-cli jsonrpc execute hostControlSafe_getActiveSessions \"$clients\""
# Führe den Befehl für jeden Schlüssel aus
opsi-cli jsonrpc execute hostControlSafe_getActiveSessions "$clients" >> "sessions.txt" 2>> error.log
done < clients_active.txt
Code: Alles auswählen
nb2115.domain.de
nb2121.domain.de
nb2122.domain.de
Code: Alles auswählen
╭─ Error ──────────────────────────────────────────────────────────────────────╮
│ Opsi rpc error: RPCHostControlMixin.hostControlSafe_getActiveSessions() │
│ takes from 1 to 2 positional arguments but 3 were given │
╰──────────────────────────────────────────────────────────────────────────────╯
Code: Alles auswählen
# Befehl in einer Variablen speichern
command="opsi-cli jsonrpc execute hostControlSafe_getActiveSessions \"$clients\" >> \"sessions.txt\""
# Debugging-Ausgabe
echo "$command" >> command.txt
Code: Alles auswählen
opsi-cli jsonrpc execute hostControlSafe_getActiveSessions "nb2115.domain.de" >> "sessions.txt"
opsi-cli jsonrpc execute hostControlSafe_getActiveSessions "nb2121.domain.de" >> "sessions.txt"
opsi-cli jsonrpc execute hostControlSafe_getActiveSessions "nb2122.domain.de" >> "sessions.txt"
Führe ich die Datei ./command.txt direkt in der Kommandozeile aus, funktionieren die Befehle.
Hat jemand eine Idee, warum das, so ist und wie ich, dass alles in einem Skript erledigen kann?