Unten ist das Skript.
Ich wollte mehrere Server anmelden und nach der Kernelversion suchen.
#!/bin/bash
#input server names line by line in server.txt
cat server.txt | while read line
do
sshpass -p password ssh root@$line << EOF
hostname
uname -r
EOF
done
Ich würde eine Ausgabe erwarten, die wie folgt geht.
server1_hostname
kernel_version
server2_hostname
kernel_version
und so weiter..
Ich habe dieses Skript mit ungefähr 80 Servern in server.txt ausgeführt
Und die Ausgabe, die ich bekam, war wie .....
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
========================================================================
================================ WARNING ===============================
========================================================================
This system is solely for the use of authorized personnel. Individuals
using this system are subject to having some or all of their activities
monitored and recorded. Anyone using this system expressly consents to
such monitoring and is advised that any unauthorized or improper use of
this system may result in disciplinary action up to and including
termination of employment. Violators may also be subject to civil and/or
criminal penalties.
========================================================================
Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.
xxxxdev01
2.6.32-431.23.3.el6.x86_64
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Pseudo-terminal will not be allocated because stdin is not a terminal.
Hier habe ich nur für 1 Host ausgegeben, xxxxdev01
und das kommt auch mit dem SSH-Banner und anderen Warnungen.
Ich brauche die Ausgabe aller anderen Hosts und ohne SSH-Banner. Was läuft hier falsch?
ssh -t -t root@
..., um ein Pseudo-Terminal zu erzwingen.
sshpass -p password root@server histname
?