Ssh does not support sqlplus and sudo -i?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ssh does not support sqlplus and sudo -i?
# 1  
Old 03-04-2016
Blade 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.
Code:
ssh -nq <host> -l <user> /usr/bin/sudo -u <orauser> -i sqlplus / as sysdba

With the following, the result is the same
Code:
ssh -nq <host> -l <user> "/usr/bin/sudo -u <orauser> -i sqlplus / as sysdba"

The result is:
Code:
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:
Code:
ssh -nq <host> -l <user> "/usr/bin/sudo -u <orauser> -i echo 'show sga' | sqlplus / as sysdba"
bash: sqlplus: command not found

Code:
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.

Last edited by h1kelds; 03-04-2016 at 05:24 AM..
# 2  
Old 03-04-2016
Try specifying the full path to sqlplus binary.

Hope that helps
Regards
Peasant.
# 3  
Old 03-04-2016
OK, how should I execute the full command then?
Code:
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?
# 4  
Old 03-04-2016
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

SSH Protocol Support

Hi there, I learnt about a case where SSH-1.99 is supported by SSH service, both SSH 1.5 and 2.0 is special. Btw, I want to know what kind of authentication mechanism are supported by SSH, here is what I thought of: Public/ Private Key Pair Password Authentication (1 Reply)
Discussion started by: alvinoo
1 Replies

2. Shell Programming and Scripting

Sqlplus not working through ssh

Hi Gurus, I was trying to execute sqlplus command remotely like ssh -q IP venkat@"which sqlplus" am getting error as which: no sqlplus in (/usr/local/bin:/bin:/usr/bin) if i connect manually and executing which sqlplus it working fine. Please help to fix the issue. Regard's Venky (7 Replies)
Discussion started by: venky.b5
7 Replies

3. Cybersecurity

Help on Ssh using sudo

I'm confused in the configuration of sudoers for one group of users. The users need to execute a app from a remote machine, in this local machine they want me to allow ssh for them using sudo for eg. sudo -u admin ssh -X euadmin@<IP address of remote> <remote script which opens a gui> It... (1 Reply)
Discussion started by: anandk
1 Replies

4. Shell Programming and Scripting

Ssh not supporting sudo and sqlplus commands

Hi Guys , I was facing an issue some thing like , I have to connect remote machine and should execute few commands over there , I am able to run some simple commands , but below commands are throws error like not found. eg : sudo su - username and sqlplus user/pwd@db , srvrmgr commands etc ... (8 Replies)
Discussion started by: chandini
8 Replies

5. Programming

Using Commands over SSH using Sudo

Is there a way to transfer my sudo password via ssh so that I can copy files remotely and pass them locally, so: cat sudo-passwd-file|ssh -t user@10.7.0.180 'sudo find / -depth|cpio -oacv|gzip' > /path/to/dir/file.cpio.gz I am in the process of a creating a script. Everytime I try and just... (16 Replies)
Discussion started by: metallica1973
16 Replies

6. Shell Programming and Scripting

ssh foo.com sudo command - Prompts for sudo password as visible text. Help?

I am writing a BASH script to update a webserver and then restart Apache. It looks basically like this: #!/bin/bash rsync /path/on/local/machine/ foo.com:path/on/remote/machine/ ssh foo.com sudo /etc/init.d/apache2 reloadrsync and ssh don't prompt for a password, because I have DSA encryption... (9 Replies)
Discussion started by: fluoborate
9 Replies

7. UNIX for Advanced & Expert Users

ssh and sudo login

Hi, I am trying to execute some command, via ssh and sudo. Here is what i want to do. ssh localhost | sudo su - ldaprole | ls -ltrh However, this command gives me listing of my home directory, and not of ldaprole. If I logic directly, when i perform sudo su - ldaprole, it... (5 Replies)
Discussion started by: john_prince
5 Replies

8. UNIX for Advanced & Expert Users

sudo and ssh

Hi, I would like to know how i can perform a task, while performing ssh, sudo and command at the same time. What I generally do is I ssh to the server, where i created private and public, so it does not prompt me for password all the time. Then i need to run "sudo su - ldaprole" to get into... (9 Replies)
Discussion started by: john_prince
9 Replies

9. UNIX for Advanced & Expert Users

sudo and ssh

Hello, Can you config sudo to use the passphrase in the user ssh-key instead of the one in the passwd? Some users do not have local passwords on the system and instead of adding the NOPASSWD in sudoers I would like the solution I asked about above. Thx Jocke (3 Replies)
Discussion started by: jOOc
3 Replies

10. UNIX for Advanced & Expert Users

xwindows over ssh after sudo?

ok...I'm stumped on this one. I cannot figure out how to carry over my environment variables with a sudo command. I need to install an application under root and only have sudo access to get there. I can use ssh -Y <host> and launch an xwindows session successfully as myself but as soon as I sudo... (3 Replies)
Discussion started by: scottsl
3 Replies
Login or Register to Ask a Question