- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ssh executing commands on a remote server.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2007 08:28 AM
тАО12-28-2007 08:28 AM
eg. ssh user@rserver "sql .."
If I append the sql statement at the end of the .profile of the user@rserver, the sql works. Any other way, the command doesn't work.
Jacques
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2007 08:45 AM
тАО12-28-2007 08:45 AM
Re: ssh executing commands on a remote server.
Do you get the same results if using the -n option with ssh?
ssh -n user@rserver "sql ..."
-denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2007 08:45 AM
тАО12-28-2007 08:45 AM
Re: ssh executing commands on a remote server.
Better use something like the Perl DBI.
However, you could try something like this.
(note, providing SID's credentials like this is a very bad thing)
$ ssh ruser@sqlserver ORACLE_SID=BLA ORACLE_HOME=/path/to/oracle/installation echo 'select foo from v$bar;' \| /path/to/sqlplus -S username/passwd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2007 08:50 AM
тАО12-28-2007 08:50 AM
Re: ssh executing commands on a remote server.
If command is specified, it is executed on the remote host instead of a login shell.
that implies (but I haven't verified) that the profile hasn't run, and that their isn't a shell running to interpret commands.
put your sql in a script, make sure the environment is set the way you want and try running it with a full path to the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2007 08:50 AM
тАО12-28-2007 08:50 AM
Re: ssh executing commands on a remote server.
You may have a remote shell script that would actually run the SQL script. Use the following command to ssh
output=`ssh user@remote_box /home/tom/run_dbscript.sh 2>/dev/null`
Make sure that you have a SSH key defined in the remote server.
Inside run_dbscript.sh you need to have logic for connecting to database and executing the SQL procedure.
Thanks,
Srikanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2007 08:53 AM
тАО12-28-2007 08:53 AM
SolutionYou may have a remote shell script that would actually run the SQL script. Use the following command to ssh
output=`ssh user@remote_box /home/tom/run_dbscript.sh 2>/dev/null`
Make sure that you have a SSH key defined in the remote server.
Inside run_dbscript.sh you need to have logic for connecting to database and executing the SQL procedure.
sqlplus -s system/manager as sysdba << EOF
set echo on feed off veri off pages 0 head off
select database_role from V$DATABASE;
exit
EOF
Thanks,
Srikanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-28-2007 10:30 AM
тАО12-28-2007 10:30 AM