1

I am trying to execute below Unix script to fetch the Oracle version from Windows command prompt using ssh command to connect to Unix terminal.

#!/use/bin/ksh
Freport=/tmp/test.txt
cd /usr/oracle2/product/11.2.0/bin
echo "Begin" > $Freport
set +x
/usr/oracle2/product/11.2.0/bin/sqlplus -V >> $Freport
set -x
pwd >> $Freport
echo "Completed" >> $Freport

Windows command prompt output:

Begin
/usr/oracle2/product/11.2.0/bin
Completed

Same script ran in Unix server and got below output.

Putty output:

Begin

SQL*Plus: Release 11.2.0.1.0

/usr/oracle2/product/11.2.0/bin
Completed

I want to print the Oracle version in my Windows command prompt output.

Windows command prompt execution:

C:\programfiles\PUTTY>putty.exe -ssh uname@ip -pw pwd -m windowsscriptpath/test.sh

Any idea how I can solve this?

Chakkara
  • 37
  • 6
  • Can someone please help me with this? I got struck here.. Is there any option to execute the unix server script directly from windows since shell script is working fine in unix server – Chakkara Feb 15 '23 at 13:53

1 Answers1

0

I guess that sqlplus -V sends its output to stderr (file descriptor 2) rather than stdout (file descriptor 1). In order to redirect stderr, use 2>>:

sqlplus -V 2>> /tmp/test.txt
trosos
  • 339
  • 1
  • 6
  • Got an error when tried above command Error 6 initialising SQL*Plus SP2-0067: Message file sp1.msb not found SP2-0750: You may need to set ORACLE_HOME to your oracle software directory /usr/oracle2/product/11.2.0/bin Completed – Chakkara Feb 14 '23 at 13:42