Most programs you can check the version of the program remotely with:
ssh server '/path/to/program -v'
sqlplus unfortunately is more difficult. You get this message.
ssh server "/opt/ora/bin/sqlplus -V"
Error 6 initializing SQL*Plus
SP2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
Hope this helps someone in the future. This took me awhile to figure out.
ssh server"export ORACLE_HOME=/opt/oracle/oracle_19.0.0.0; /opt/ora/bin/sqlplus -V"
SQL*Plus: Release 19.0.0.0.0 - Production
Version 19.17.0.0.0
most shells allow passing an env var directly in front of the command. So this should also work:
ssh server "ORACLE_HOME=/opt/oracle/oracle_19.0.0.0 /opt/ora/bin/sqlplus -V"
From man bash:
The environment for any simple command or function may be augmented temporarily by prefixing it with parameter assignments, as described above in PARAMETERS. These assignment statements affect only the environment seen by that command.