Ssh does not support sqlplus and sudo -i?

Hey everybody,
currently I am having an issue that I need to open an ssh session to a remote host, once on the remote host I need to use sudo and then execute sqlplus. Once the sqlplus call is open I need to execute one command while the sqlplus is active. For example show sga.

I already got so far that this is working.

ssh -nq <host> -l <user> /usr/bin/sudo -u <orauser> -i sqlplus / as sysdba

With the following, the result is the same

ssh -nq <host> -l <user> "/usr/bin/sudo -u <orauser> -i sqlplus / as sysdba"

The result is:

SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 4 09:56:42 2016
 Copyright (c) 1982, 2013, Oracle.  All rights reserved.
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Now what I would like to be able to do is to get the sga values set in the DB by calling 'show sga' inside the sqlplus connection.

I already tried the following commands, which don't work:

ssh -nq <host> -l <user> "/usr/bin/sudo -u <orauser> -i echo 'show sga' | sqlplus / as sysdba"
bash: sqlplus: command not found
ssh -nq <host> -l <user> "/usr/bin/sudo -u <orauser> -i echo \"show sga\" | sqlplus / as sysdba"
 bash: sqlplus: command not found

Does anyone of you have a hint how I could solve this?

Kind regards.

Try specifying the full path to sqlplus binary.

Hope that helps
Regards
Peasant.

OK, how should I execute the full command then?

ssh -nq <host> -l <user> "/usr/bin/sudo -u <orauser> -i echo 'show sga' | /oracle/<SID>/112_64/bin/sqlplus / as sysdba"
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

The simple sqlplus command is still working.

but how can I combine these?

Do you have .profile or .bashrc (depending on the shell of the <orauser>) defined ?
Looks like you are missing the environment variables required to run sqlplus (which is stated in the error output).

If you login with <orauser> does sqlplus works from that shell ?

Hope that helps
Regards
Peasant.