Logging Remote SSH command (cannot log a java output)

Hi all

I'm creating a script that runs a few commands on some boxes and everything can be logged EXCEPT the java -version command, there doesn't seem to be any output...

Can anyone help explain why this does not work? Do I need to do something extra to append the output from the java -version command to a file on the machine that I am running the script?

Thanks!

SSH_CMD=/usr/bin/ssh
USER=root
for _host in ${LIST_HOSTS}
do
        ${SSH_CMD} ${USER}@${_host} hostname | tee -a results.txt
        ${SSH_CMD} ${USER}@${_host} 'java -version'
        ${SSH_CMD} ${USER}@${_host} 'uname -a' |tee -a results.txt
        ${SSH_CMD} ${USER}@${_host} 'prtdiag -v | grep -i OBP' |tee -a results.txt
        echo "\n" | tee -a results.txt
done

Hi.

On my system:

/Users/scott $ java -version > /dev/null
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode)

This tells me that the version information is written somewhere else (actually standard error), so, try:

${SSH_CMD} ${USER}@${_host} 'java -version 2>&1' | tee -a results.txt



That is VERY interesting!

And it worked! Thank you :slight_smile:

Does anyone know why that the java output would be considered STDER (my wild guess is that the programmers who worked on java had the output go to SDTERR? )

The words "head", "the", "on", "nail" and "hit" spring to mind!

But it doesn't really surprise me that they did it differently, although I'm sure they had their reasons :slight_smile: