LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-09-2010, 03:37 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Rep: Reputation: 33
tnsping: command not found


I want to test the listener of a database. But as I type the tnsping, it fails and show the error as follow:
Code:
-bash: tnsping: command not found
Should I install the tnsping? How?
 
Old 07-09-2010, 04:45 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
"tnsping" is an Oracle command.

You need Oracle installed on your system, and you need the Oracle programs in your search path.

To modify your $PATH, of course, you can edit your $HOME/.bashrc user environment initialization file.

'Hope that helps .. PSM
 
Old 07-15-2010, 04:52 AM   #3
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by paulsm4 View Post
"tnsping" is an Oracle command.

You need Oracle installed on your system, and you need the Oracle programs in your search path.

To modify your $PATH, of course, you can edit your $HOME/.bashrc user environment initialization file.

'Hope that helps .. PSM

I've installed the oracle 10 client. But couldn't find the tnsping. Seems from oralce 10 no tnsping anymore?
 
Old 07-15-2010, 09:44 AM   #4
BirdRacer
LQ Newbie
 
Registered: Feb 2008
Posts: 14

Rep: Reputation: 2
Quote:
Originally Posted by thomas2004ch View Post
I've installed the oracle 10 client. But couldn't find the tnsping. Seems from oralce 10 no tnsping anymore?
It should be in your $ORACLE_HOME/bin directory. Do this:

Code:
env | grep ORACLE_HOME
to show your $ORACLE_HOME environment variable, or just do:

Code:
cd $ORACLE_HOME/bin
to put you in that directory, then do an 'ls -l tnsping' to see the file. If that is correct, then do:

Code:
PATH=$PATH:$ORACLE_HOME/bin ; export PATH
to add it to your PATH variable. You would want to put this in your .bashrc or .bash_profile to make it permanent.
 
Old 01-14-2023, 01:55 PM   #5
DanDMKE
LQ Newbie
 
Registered: Jan 2023
Posts: 1

Rep: Reputation: 0
tnsping implemented as ksh script

You probably have an Oracle Instant Client. That client install option does not come with the 'tnsping' command.
I think you can get 'sqlplus' command as an optional RPM package.

Anyhow, I wrote my own 'tnsping' using a Korn shell script, which relies upon 'sqlplus' command being installed and tnsnames.ora file.
Entries in tnsnames.ora are case-insensitive. We do a fake login (regit / tiger) with 'sqlplus' command and watch for the expected login error.
If we get the login error, we display 'OK' along with how many milliseconds it took to run the 'sqlplus' attempt.
If we get something else, we display that error (either ORA-xxxxx or TNS-xxxxx).

This is intended to be a quick and dirty solution to my immediate need, on RHEL 8.7
If you find it useful, GREAT!

Code:
#!/bin/ksh

if [[ "X$1" == "X" ]]
then
   echo "Usage: tnsping <DB_instance>"
   exit 1
fi

if [[ "X${TNS_ADMIN}" == "X" ]]
then
   echo "Oracle environment variable TNS_ADMIN is not set."
   echo 10
fi

if [[ "X${ORACLE_HOME}" == "X" ]]
then
   echo "Oracle environment variable ORACLE_HOME is not set."
   echo 20
fi

if [ ! -f ${TNS_ADMIN}/tnsnames.ora ]
then
   if [ -f ${ORACLE_HOME}/network/admin/tnsnames.ora ]
   then
      TNS_ADMIN=${ORACLE_HOME}/network/admin
   else
      echo "${TNS_ADMIN}/tnsnames.ora does not exist"
      exit 30
   fi
fi

chk=$(grep -ic $1 ${TNS_ADMIN}/tnsnames.ora)
if [ ${chk} -eq 0 ]
then
   echo "Entry $1 not found in tnsnames.ora"
   exit 40
else
   db_inst=$1
fi

tmp_file=/tmp/tnsping.$$

st_time=$(echo $SECONDS | sed 's#\.##')
${ORACLE_HOME}/bin/sqlplus -L -S regit/tiger@${db_inst} > ${tmp_file} 2>&1
en_time=$(echo $SECONDS | sed 's#\.##')

el_time=$(expr ${en_time} - ${st_time})

chk=$(grep -c 'ORA-01017: invalid username/password; logon denied' ${tmp_file})
if [ ${chk} -gt 0 ]
then
   echo "OK (${el_time} msec)"
else
   grep -E 'ORA-|TNS-' ${tmp_file}
fi

/bin/rm -f ${tmp_file}

exit 0
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
setup command not found in Ubuntu 10.04 Command Prompt vinaytp Ubuntu 2 05-06-2010 01:10 PM
Shell: command not found / Runs fine with "Run command" badbunny Linux - Newbie 1 01-22-2007 01:21 AM
bash: rpm: command not found && sudo: alien: command not found Java_Code Ubuntu 7 07-27-2006 11:57 PM
bash: <command name> command not found smash Programming 5 03-13-2006 08:48 AM
tnsping : TNS-12541: TNS: no listener hpmface Linux - Networking 4 05-31-2004 12:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration