How to connect to a DB installed on another host using shell script?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers How to connect to a DB installed on another host using shell script?
# 8  
Old 02-16-2019
Thank you for getting back. When i use sqlplus or tnsping, both of them return 'command not found' error on Host A probably because oracle client is not installed on host A but is on Host B.
# 9  
Old 02-20-2019
Hi Experts

This is the code on Host A:

<
Code:
rval1=0
#local checkDB
checkDB=$(ssh user@host
expect "password"
send "password\r"
interact
/home/test.sh)
echo $?

/>

Code on Host B:

<
Code:
rval=0

#Check if DB is up
ps -ef|grep -v grep|grep pmon > /dev/null
rval=$?
if (( $rval == 0 ))
then
   echo "DB is up and running."
else
    echo "Waiting for DB to start"
fi

while [ "$rval" != "0" ]
 do
    echo " Trying again after 10 seconds"
    sleep 10
ps -ef|grep -v grep|grep pmon > /dev/null
rval=$?
echo "DB is up and running."
done
exit $rval

/>

When i run the script on host A, it again prompts for password and when i explicitly give the password, it keeps running without exit and when i kill the process id on host B, then the below errors are shown on Host A:

Code:
user@host's password:
Connection to uslxcd1619 closed by remote host.
Connection to uslxcd1619 closed.
couldn't read file "password": no such file or directory
./filename.sh: line 9: send: command not found
./filename.sh: line 10: interact: command not found
 ./filename.sh: line 11: /home/test.sh: No such file or directory




Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 02-20-2019 at 07:07 AM.. Reason: Added CODE tags.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to connect

hello i try to made a report to conect all database to diferent OS HP-UX/LINUX/SOLARIS/AIX this is my example i have 5 db OS are HP-UX ps -fea | grep pmon root 1120 1 0 Nov 29 ? 5:14 ipmon -sD oracle 10286 1 0 Nov 29 ? 27:19 ora_pmon_BD1 oracle 10431... (7 Replies)
Discussion started by: ceciaide
7 Replies

2. Shell Programming and Scripting

Connect to target host from Source host.

Hi All, Need to connect to target host and execute a command and connect back to source host to continue with next set of command execution. Is there a utility/command using which we can connect to target host ? Please suggest. Note: Netezza database is instaled on Linux server. ... (4 Replies)
Discussion started by: Nagaraja Akkiva
4 Replies

3. Shell Programming and Scripting

CURL getting Error- couldn't connect to host

Hi i am trying to open HTTP by curl command. i am tryng to do that from command or script BASH. also iptables is off it doesnt work i am getting an error: curl: (7) coudn't connect to host the scipt is: #! /bin/bash curl http://www.cnn.com (1 Reply)
Discussion started by: zigizag
1 Replies

4. Shell Programming and Scripting

Portable Shell Script - Determine Which Version of Binary is Installed?

I currently have a shell script that utilizes the "Date" binary - this application is slightly different on OS X (BSD General Commmand) and Linux systems (gnu date). In particular, the version on OS X requires the following to get a date 14 days in the future "date -v+14d -u +%Y-%m-%d" where gnu... (1 Reply)
Discussion started by: colinjohnson
1 Replies

5. Shell Programming and Scripting

Connect to Oracle in Windows XP from Linux HOST

Hi everyone, I have oracle 9i installed in Windows XP and i have ubuntu in VM WARE. I would like to know how to connect to Oracle in windows xp from Linux through shel scripting...... (3 Replies)
Discussion started by: Zimbu
3 Replies

6. Red Hat

Installed apache server , can't connect from outside (using CentOS in WMware )

Hello all I installed apache in CentOS 5.5 ,after searching the web for tips on configuration I did the fallowing stuff to unable connecting the http server from outside. In /etc/httpd/conf/httpd.conf I changed the Listen value to 0.0.0.8011 Then checked with then check with: netstat -anp and I... (2 Replies)
Discussion started by: umen
2 Replies

7. Shell Programming and Scripting

How to use ssh execute other shell script on other host (shell script include nohup)?

i want use ssh on the host01 to execute autoexec.sh on the host02 like following : host01> ssh host02 autoexec.sh autoexec.sh include nohup command like follwing : nohup /home/jack/deletedata.sh & after i execute ssh host02 autoexec.sh one the host01. i can't found deletedata.sh... (1 Reply)
Discussion started by: orablue
1 Replies

8. Shell Programming and Scripting

Run a shell script from one host which connext to remote host and run the commands

I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running... (6 Replies)
Discussion started by: SN2009
6 Replies

9. Shell Programming and Scripting

How can my unix shell script automatically connect to remote host?

How can my unix shell script automatically connect to remote host? Assume that there is a remote host called "rhost". When I connect to that host i give the command "telnet rhost". It then asks me for my id and password. Once i give it connects there. I want to automate these steps. I want... (8 Replies)
Discussion started by: digdarshan
8 Replies

10. UNIX for Advanced & Expert Users

sendmail : connect local host (brocken)

hi there I've got a strange problem with a webserver box (suse linux 7.2). My MTA is sendmail, and when I tried manually send a mail. Sendmail -v "user@something" < /etc/hosts The Server tried "simon@localhost... Connecting to local..." but nothing happend and the system hold on. This... (3 Replies)
Discussion started by: mrsaint
3 Replies
Login or Register to Ask a Question