RE: Re: Shell scripting

2002-10-08 Thread Kevin Lange

Ahhh  I had not seen that part of the response.   Well, now they have a
sample of just how complicated it can get.

-Original Message-
Sent: Tuesday, October 08, 2002 12:14 PM
To: Multiple recipients of list ORACLE-L


Kevin,

Thanks for the 'coprocess', I couldn't remember what it was called.

This is what I was describing in my previous email.

Jared





Kevin Lange <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
 10/08/2002 09:23 AM
 Please respond to ORACLE-L

 
To: Multiple recipients of list ORACLE-L <[EMAIL PROTECTED]>
cc: 
        Subject:RE: Re: Shell scripting


Actually Jared, you can by setting up a sqlplus coprocess and using unix
pipes.  The routine below will get a parameter from the v$parameter table
using sqlplus.

Kevin


=== 

get_db_parm()
{
  unset vRETURNED_PARM
  unset vRESPONSE

  typeset -u vPARM

  vPARM=$1

  sqlplus -silent /NOLOG |&
  print -p 'set feedback off'
  print -p 'set echo off'
  print -p 'set heading off'
  print -p 'set pagesize 0'
  print -p 'connect internal'

  read -p vRESPONSE
  while [ "${vRESPONSE:-Z}" != 'Connected.' -a \
  "${vRESPONSE%ORA*}Z" != 'Z' ]
  do
read -p vRESPONSE
  done

  if [ "${vRESPONSE:-Z}" = Z ] ; then
 return 1
  fi

  vTERMINATOR='Z'
  print -p "SELECT UPPER(name)||':'||value t FROM v\$parameter"
  print -p "WHERE UPPER(name) = '"${vPARM}"'"
  print -p "UNION"
  print -p "SELECT '${vTERMINATOR}' t FROM dual"
  print -p "ORDER BY 1;"

  read -p vRESPONSE

  while [ "${vRESPONSE}" != ${vTERMINATOR} ]
  do
if [ "${vRESPONSE%%:*}" = $vPARM ] ; then
 vRETURNED_PARM=${vRESPONSE##*:}
  if [ "${vRETURNED_PARM%%\?*}Z" = Z ] ; then
vRETURNED_PARM=${ORACLE_HOME}${vRETURNED_PARM#\?}
  fi
fi
read -p vRESPONSE
  done

  print -p "exit"

  # Flush Buffer after exiting
  while [ $? -eq 0 ]
  do
read -p $vRESPONSE
  done

  vRETURNED_PARM=`echo $vRETURNED_PARM|sed "s/%/%%/g"`

  printf "${vRETURNED_PARM}\n"

  return 0
}

-Original Message-
Sent: Tuesday, October 08, 2002 10:24 AM
To: Multiple recipients of list ORACLE-L



Omar,

If what you mean is:

"How do I send a value from sqlplus plus directly
to a variable in my shell environment?"

You can't.

What you've done is the way it is usually done.

Another way to do it is to use the '&|' korn shell mechanism.

e.g.
  sqlplus  -silent scott/tiger@$ORACLE_SID |&

This allows you to send commands straight to sqlplus
from the ksh command line, and retrieve the results
of queries from the cmd line.

It's not as easy as it appears.  I wrote a set of shell functions
once upon a time to do this, and it gets more complex than
you expect.

The method you are currently using works ok. 

Of course, you could use Perl with DBI and avoid all this
subshell nonsense.

Jared


On Tuesday 08 October 2002 01:23, Cyril Thankappan wrote:
> Sure
>
> THanks Omar
>
> But I was looking for a
> 'non-file based' solution :)
>
> Thanks anyway
>
> On Mon, 07 Oct 2002 Omar Khalid wrote :
> >hi
> >
> >well i think i did this once, you can read
> >the output of the SQL query into shell variables by
> >first  redirecting the output of the SQL query to an
> >OS file and then reading the file and loading
> >the data in the file into shell variables.
> >
> >/* here is sample code to redirect the output  of sql query to OS
> >file */
> >
> >#!/bin/sh
> >
> >CMD_FILE=sql_input.sql
> >LOC_FILE=output.log
> >
> >  SQLCMD="connect internal ;
> >   select * from sys.dba_users ;"
> >  echo "$SQLCMD" > ${CMD_FILE}
> >
> >  svrmgrl < ${CMD_FILE} > ${LOC_FILE} /* redirecting the
> >out of
> >svrmgrl to OS file */
> >
> >regards
> >'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'
> >Omar Khalid
> >Software Engineer
> >LMK Resources
> >Voice: 111-101-101*780
> >Mobile: 0333-510-4465
> >Web: www.lmkr.com
> >'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > "Cyril
> > Thankappan"  To: Multiple
> >recipients of list ORACLE-L <[EMAIL PROTECTED]>
> >  >   

RE: Re: Shell scripting

2002-10-08 Thread Jared . Still

Kevin,

Thanks for the 'coprocess', I couldn't remember what it was called.

This is what I was describing in my previous email.

Jared





Kevin Lange <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
 10/08/2002 09:23 AM
 Please respond to ORACLE-L

 
To: Multiple recipients of list ORACLE-L <[EMAIL PROTECTED]>
cc: 
        Subject:RE: Re: Shell scripting


Actually Jared, you can by setting up a sqlplus coprocess and using unix
pipes.  The routine below will get a parameter from the v$parameter table
using sqlplus.

Kevin


=== 

get_db_parm()
{
  unset vRETURNED_PARM
  unset vRESPONSE

  typeset -u vPARM

  vPARM=$1

  sqlplus -silent /NOLOG |&
  print -p 'set feedback off'
  print -p 'set echo off'
  print -p 'set heading off'
  print -p 'set pagesize 0'
  print -p 'connect internal'

  read -p vRESPONSE
  while [ "${vRESPONSE:-Z}" != 'Connected.' -a \
  "${vRESPONSE%ORA*}Z" != 'Z' ]
  do
read -p vRESPONSE
  done

  if [ "${vRESPONSE:-Z}" = Z ] ; then
 return 1
  fi

  vTERMINATOR='Z'
  print -p "SELECT UPPER(name)||':'||value t FROM v\$parameter"
  print -p "WHERE UPPER(name) = '"${vPARM}"'"
  print -p "UNION"
  print -p "SELECT '${vTERMINATOR}' t FROM dual"
  print -p "ORDER BY 1;"

  read -p vRESPONSE

  while [ "${vRESPONSE}" != ${vTERMINATOR} ]
  do
if [ "${vRESPONSE%%:*}" = $vPARM ] ; then
 vRETURNED_PARM=${vRESPONSE##*:}
  if [ "${vRETURNED_PARM%%\?*}Z" = Z ] ; then
vRETURNED_PARM=${ORACLE_HOME}${vRETURNED_PARM#\?}
  fi
fi
read -p vRESPONSE
  done

  print -p "exit"

  # Flush Buffer after exiting
  while [ $? -eq 0 ]
  do
read -p $vRESPONSE
  done

  vRETURNED_PARM=`echo $vRETURNED_PARM|sed "s/%/%%/g"`

  printf "${vRETURNED_PARM}\n"

  return 0
}

-Original Message-
Sent: Tuesday, October 08, 2002 10:24 AM
To: Multiple recipients of list ORACLE-L



Omar,

If what you mean is:

"How do I send a value from sqlplus plus directly
to a variable in my shell environment?"

You can't.

What you've done is the way it is usually done.

Another way to do it is to use the '&|' korn shell mechanism.

e.g.
  sqlplus  -silent scott/tiger@$ORACLE_SID |&

This allows you to send commands straight to sqlplus
from the ksh command line, and retrieve the results
of queries from the cmd line.

It's not as easy as it appears.  I wrote a set of shell functions
once upon a time to do this, and it gets more complex than
you expect.

The method you are currently using works ok. 

Of course, you could use Perl with DBI and avoid all this
subshell nonsense.

Jared


On Tuesday 08 October 2002 01:23, Cyril Thankappan wrote:
> Sure
>
> THanks Omar
>
> But I was looking for a
> 'non-file based' solution :)
>
> Thanks anyway
>
> On Mon, 07 Oct 2002 Omar Khalid wrote :
> >hi
> >
> >well i think i did this once, you can read
> >the output of the SQL query into shell variables by
> >first  redirecting the output of the SQL query to an
> >OS file and then reading the file and loading
> >the data in the file into shell variables.
> >
> >/* here is sample code to redirect the output  of sql query to OS
> >file */
> >
> >#!/bin/sh
> >
> >CMD_FILE=sql_input.sql
> >LOC_FILE=output.log
> >
> >  SQLCMD="connect internal ;
> >   select * from sys.dba_users ;"
> >  echo "$SQLCMD" > ${CMD_FILE}
> >
> >  svrmgrl < ${CMD_FILE} > ${LOC_FILE} /* redirecting the
> >out of
> >svrmgrl to OS file */
> >
> >regards
> >'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'
> >Omar Khalid
> >Software Engineer
> >LMK Resources
> >Voice: 111-101-101*780
> >Mobile: 0333-510-4465
> >Web: www.lmkr.com
> >'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > "Cyril
> > Thankappan"  To: Multiple
> >recipients of list ORACLE-L <[EMAIL PROTECTED]>
> >  > fmail.com>   Subject: Shell
> >scripting
> > Sent by:
> > [EMAIL PROTECTED]
> >
> >
> > 10/04/2002 09:18
>

RE: Re: Shell scripting

2002-10-08 Thread Kevin Lange

Actually Jared, you can by setting up a sqlplus coprocess and using unix
pipes.  The routine below will get a parameter from the v$parameter table
using sqlplus.

Kevin


=== 

get_db_parm()
{
  unset vRETURNED_PARM
  unset vRESPONSE

  typeset -u vPARM

  vPARM=$1

  sqlplus -silent /NOLOG |&
  print -p 'set feedback off'
  print -p 'set echo off'
  print -p 'set heading off'
  print -p 'set pagesize 0'
  print -p 'connect internal'

  read -p vRESPONSE
  while [ "${vRESPONSE:-Z}" != 'Connected.' -a \
  "${vRESPONSE%ORA*}Z" != 'Z' ]
  do
read -p vRESPONSE
  done

  if [ "${vRESPONSE:-Z}" = Z ] ; then
 return 1
  fi

  vTERMINATOR='Z'
  print -p "SELECT UPPER(name)||':'||value t FROM v\$parameter"
  print -p "WHERE UPPER(name) = '"${vPARM}"'"
  print -p "UNION"
  print -p "SELECT '${vTERMINATOR}' t FROM dual"
  print -p "ORDER BY 1;"

  read -p vRESPONSE

  while [ "${vRESPONSE}" != ${vTERMINATOR} ]
  do
if [ "${vRESPONSE%%:*}" = $vPARM ] ; then
 vRETURNED_PARM=${vRESPONSE##*:}
  if [ "${vRETURNED_PARM%%\?*}Z" = Z ] ; then
vRETURNED_PARM=${ORACLE_HOME}${vRETURNED_PARM#\?}
  fi
fi
read -p vRESPONSE
  done

  print -p "exit"

  # Flush Buffer after exiting
  while [ $? -eq 0 ]
  do
read -p $vRESPONSE
  done

  vRETURNED_PARM=`echo $vRETURNED_PARM|sed "s/%/%%/g"`

  printf "${vRETURNED_PARM}\n"

  return 0
}

-Original Message-
Sent: Tuesday, October 08, 2002 10:24 AM
To: Multiple recipients of list ORACLE-L



Omar,

If what you mean is:

"How do I send a value from sqlplus plus directly
to a variable in my shell environment?"

You can't.

What you've done is the way it is usually done.

Another way to do it is to use the '&|' korn shell mechanism.

e.g.
  sqlplus  -silent scott/tiger@$ORACLE_SID |&

This allows you to send commands straight to sqlplus
from the ksh command line, and retrieve the results
of queries from the cmd line.

It's not as easy as it appears.  I wrote a set of shell functions
once upon a time to do this, and it gets more complex than
you expect.

The method you are currently using works ok.  

Of course, you could use Perl with DBI and avoid all this
subshell nonsense.

Jared


On Tuesday 08 October 2002 01:23, Cyril Thankappan wrote:
> Sure
>
> THanks Omar
>
> But I was looking for a
> 'non-file based' solution :)
>
> Thanks anyway
>
> On Mon, 07 Oct 2002 Omar Khalid wrote :
> >hi
> >
> >well i think i did this once, you can read
> >the output of the SQL query into shell variables by
> >first  redirecting the output of the SQL query to an
> >OS file and then reading the file and loading
> >the data in the file into shell variables.
> >
> >/* here is sample code to redirect the output  of sql query to OS
> >file */
> >
> >#!/bin/sh
> >
> >CMD_FILE=sql_input.sql
> >LOC_FILE=output.log
> >
> >  SQLCMD="connect internal ;
> >   select * from sys.dba_users ;"
> >  echo "$SQLCMD" > ${CMD_FILE}
> >
> >  svrmgrl < ${CMD_FILE} > ${LOC_FILE} /* redirecting the
> >out of
> >svrmgrl to OS file */
> >
> >regards
> >'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'
> >Omar Khalid
> >Software Engineer
> >LMK Resources
> >Voice: 111-101-101*780
> >Mobile: 0333-510-4465
> >Web: www.lmkr.com
> >'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > "Cyril
> > Thankappan"  To: Multiple
> >recipients of list ORACLE-L <[EMAIL PROTECTED]>
> >  > fmail.com>   Subject: Shell
> >scripting
> > Sent by:
> > [EMAIL PROTECTED]
> >
> >
> > 10/04/2002 09:18
> > PM
> > Please respond to
> > ORACLE-L
> >
> >
> >
> >
> >
> >
> >Hi
> >
> >I wanted to select a column from a v$ table
> >
> >struggled with it
> >and finally came with a workaround as follows
> >
> >
> >
> >archived_log='$archived_log'
> >begin_seq=`sqlplus -s /nolog < >connect / as sysdba
> >set head off
> >set echo off
> >set feedback off
> >set verify off
> >select max(sequence#)-1 from v$archived_log ;
> >exit
> >EOF`
> >echo $begin_seq
> >
> >---
> >
> >However, the question is how to
> >'directly' take the output into a shell variable?
> >there 'shud be' a better workaround than this !
> >
> >Thanks
> >--
> >Please see the official ORACLE-L FAQ: http://www.orafaq.com
> >--
> >Author: Cyril  Thankappan
> >   INET: [EMAIL PROTECTED]
> >
> >Fat City Network Services-- 858-538-5051
> >http://www.fatcity.com
> >San Diego, California-- Mailing list and web hosting
> >services
> >-
> >To REMOVE yourself from this mailing list, send an E-Mail
> >message
> >to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and
> >i

Re: Re: Shell scripting

2002-10-08 Thread Jared Still


Omar,

If what you mean is:

"How do I send a value from sqlplus plus directly
to a variable in my shell environment?"

You can't.

What you've done is the way it is usually done.

Another way to do it is to use the '&|' korn shell mechanism.

e.g.
  sqlplus  -silent scott/tiger@$ORACLE_SID |&

This allows you to send commands straight to sqlplus
from the ksh command line, and retrieve the results
of queries from the cmd line.

It's not as easy as it appears.  I wrote a set of shell functions
once upon a time to do this, and it gets more complex than
you expect.

The method you are currently using works ok.  

Of course, you could use Perl with DBI and avoid all this
subshell nonsense.

Jared


On Tuesday 08 October 2002 01:23, Cyril Thankappan wrote:
> Sure
>
> THanks Omar
>
> But I was looking for a
> 'non-file based' solution :)
>
> Thanks anyway
>
> On Mon, 07 Oct 2002 Omar Khalid wrote :
> >hi
> >
> >well i think i did this once, you can read
> >the output of the SQL query into shell variables by
> >first  redirecting the output of the SQL query to an
> >OS file and then reading the file and loading
> >the data in the file into shell variables.
> >
> >/* here is sample code to redirect the output  of sql query to OS
> >file */
> >
> >#!/bin/sh
> >
> >CMD_FILE=sql_input.sql
> >LOC_FILE=output.log
> >
> >  SQLCMD="connect internal ;
> >   select * from sys.dba_users ;"
> >  echo "$SQLCMD" > ${CMD_FILE}
> >
> >  svrmgrl < ${CMD_FILE} > ${LOC_FILE} /* redirecting the
> >out of
> >svrmgrl to OS file */
> >
> >regards
> >'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'
> >Omar Khalid
> >Software Engineer
> >LMK Resources
> >Voice: 111-101-101*780
> >Mobile: 0333-510-4465
> >Web: www.lmkr.com
> >'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > "Cyril
> > Thankappan"  To: Multiple
> >recipients of list ORACLE-L <[EMAIL PROTECTED]>
> >  > fmail.com>   Subject: Shell
> >scripting
> > Sent by:
> > [EMAIL PROTECTED]
> >
> >
> > 10/04/2002 09:18
> > PM
> > Please respond to
> > ORACLE-L
> >
> >
> >
> >
> >
> >
> >Hi
> >
> >I wanted to select a column from a v$ table
> >
> >struggled with it
> >and finally came with a workaround as follows
> >
> >
> >
> >archived_log='$archived_log'
> >begin_seq=`sqlplus -s /nolog < >connect / as sysdba
> >set head off
> >set echo off
> >set feedback off
> >set verify off
> >select max(sequence#)-1 from v$archived_log ;
> >exit
> >EOF`
> >echo $begin_seq
> >
> >---
> >
> >However, the question is how to
> >'directly' take the output into a shell variable?
> >there 'shud be' a better workaround than this !
> >
> >Thanks
> >--
> >Please see the official ORACLE-L FAQ: http://www.orafaq.com
> >--
> >Author: Cyril  Thankappan
> >   INET: [EMAIL PROTECTED]
> >
> >Fat City Network Services-- 858-538-5051
> >http://www.fatcity.com
> >San Diego, California-- Mailing list and web hosting
> >services
> >-
> >To REMOVE yourself from this mailing list, send an E-Mail
> >message
> >to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and
> >in
> >the message BODY, include a line containing: UNSUB ORACLE-L
> >(or the name of mailing list you want to be removed from).  You
> >may
> >also send the HELP command for other information (like
> >subscribing).
> >
> >
> >
> >
> >--
> >Please see the official ORACLE-L FAQ: http://www.orafaq.com
> >--
> >Author: Omar Khalid
> >   INET: [EMAIL PROTECTED]
> >
> >Fat City Network Services-- 858-538-5051
> >http://www.fatcity.com
> >San Diego, California-- Mailing list and web hosting
> >services
> >-
> >To REMOVE yourself from this mailing list, send an E-Mail
> >message
> >to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and
> >in
> >the message BODY, include a line containing: UNSUB ORACLE-L
> >(or the name of mailing list you want to be removed from).  You
> >may
> >also send the HELP command for other information (like
> >subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Jared Still
  INET: [EMAIL PROTECTED]

Fat City Network Services-- 858-538-5051 http://www.fatcity.com
San Diego, California-- Mailing list and web hosting services
-
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP co

Re: Re: Shell scripting

2002-10-08 Thread Cyril Thankappan

Sure

THanks Omar

But I was looking for a
'non-file based' solution :)

Thanks anyway

On Mon, 07 Oct 2002 Omar Khalid wrote :
>
>hi
>
>well i think i did this once, you can read
>the output of the SQL query into shell variables by
>first  redirecting the output of the SQL query to an
>OS file and then reading the file and loading
>the data in the file into shell variables.
>
>/* here is sample code to redirect the output  of sql query to OS 
>file */
>
>#!/bin/sh
>
>CMD_FILE=sql_input.sql
>LOC_FILE=output.log
>
>  SQLCMD="connect internal ;
>   select * from sys.dba_users ;"
>  echo "$SQLCMD" > ${CMD_FILE}
>
>  svrmgrl < ${CMD_FILE} > ${LOC_FILE} /* redirecting the 
>out of
>svrmgrl to OS file */
>
>regards
>'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'
>Omar Khalid
>Software Engineer
>LMK Resources
>Voice: 111-101-101*780
>Mobile: 0333-510-4465
>Web: www.lmkr.com
>'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'
>
>
>
>
>
>
>
>
>
>
>
>
>
> "Cyril
> Thankappan"  To: Multiple 
>recipients of list ORACLE-L <[EMAIL PROTECTED]>
>  fmail.com>   Subject: Shell 
>scripting
> Sent by:
> [EMAIL PROTECTED]
>
>
> 10/04/2002 09:18
> PM
> Please respond to
> ORACLE-L
>
>
>
>
>
>
>Hi
>
>I wanted to select a column from a v$ table
>
>struggled with it
>and finally came with a workaround as follows
>
>
>
>archived_log='$archived_log'
>begin_seq=`sqlplus -s /nolog set head off
>set echo off
>set feedback off
>set verify off
>select max(sequence#)-1 from v$archived_log ;
>exit
>EOF`
>echo $begin_seq
>
>---
>
>However, the question is how to
>'directly' take the output into a shell variable?
>there 'shud be' a better workaround than this !
>
>Thanks
>--
>Please see the official ORACLE-L FAQ: http://www.orafaq.com
>--
>Author: Cyril  Thankappan
>   INET: [EMAIL PROTECTED]
>
>Fat City Network Services-- 858-538-5051 
>http://www.fatcity.com
>San Diego, California-- Mailing list and web hosting 
>services
>-
>To REMOVE yourself from this mailing list, send an E-Mail 
>message
>to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and 
>in
>the message BODY, include a line containing: UNSUB ORACLE-L
>(or the name of mailing list you want to be removed from).  You 
>may
>also send the HELP command for other information (like 
>subscribing).
>
>
>
>
>--
>Please see the official ORACLE-L FAQ: http://www.orafaq.com
>--
>Author: Omar Khalid
>   INET: [EMAIL PROTECTED]
>
>Fat City Network Services-- 858-538-5051 
>http://www.fatcity.com
>San Diego, California-- Mailing list and web hosting 
>services
>-
>To REMOVE yourself from this mailing list, send an E-Mail 
>message
>to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and 
>in
>the message BODY, include a line containing: UNSUB ORACLE-L
>(or the name of mailing list you want to be removed from).  You 
>may
>also send the HELP command for other information (like 
>subscribing).

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Cyril  Thankappan
  INET: [EMAIL PROTECTED]

Fat City Network Services-- 858-538-5051 http://www.fatcity.com
San Diego, California-- Mailing list and web hosting services
-
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



Re: Shell scripting

2002-10-06 Thread Omar Khalid


hi

well i think i did this once, you can read
the output of the SQL query into shell variables by
first  redirecting the output of the SQL query to an
OS file and then reading the file and loading
the data in the file into shell variables.

/* here is sample code to redirect the output  of sql query to OS file */

#!/bin/sh

CMD_FILE=sql_input.sql
LOC_FILE=output.log

 SQLCMD="connect internal ;
  select * from sys.dba_users ;"
 echo "$SQLCMD" > ${CMD_FILE}

 svrmgrl < ${CMD_FILE} > ${LOC_FILE} /* redirecting the out of
svrmgrl to OS file */

regards
'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'
Omar Khalid
Software Engineer
LMK Resources
Voice: 111-101-101*780
Mobile: 0333-510-4465
Web: www.lmkr.com
'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'_-_'


   

   

   



   
   
   
   
   
   


   

"Cyril 

Thankappan"  To: Multiple recipients of list 
ORACLE-L <[EMAIL PROTECTED]>   
   Subject: Shell scripting  

Sent by:   

[EMAIL PROTECTED]   

   

   

10/04/2002 09:18   

PM 

Please respond to  

ORACLE-L   

   

   





Hi

I wanted to select a column from a v$ table

struggled with it
and finally came with a workaround as follows



archived_log='$archived_log'
begin_seq=`sqlplus -s /nolog 

RE: Shell scripting question

2001-02-23 Thread John Dailey

Yep... that's what I get for taking someone's word.   I got handed this
problem after everybody else gave up on it... all I heard was "man pages
didn't tell us anything"...  HAHAHAHAHA   <-- my insane laughter now

Anyway, thanks to all who responded to my query... Bill, Ganti, and the user
below were all very helpful (especially Bill for putting up with me twice).
BTW, before I saw this note, I got the .netrc file suggested by Ganti to
work... fixed the problem nicely.  Will probably just stay with that
solution out of pride/embarrassment.  Just had to insure the .netrc file had
0 bits for group and other permissions in the user's home directory.

Thanks again to the list.

John Dailey

-Original Message-
Sent: Friday, February 23, 2001 3:26 PM
To: Multiple recipients of list ORACLE-L


check out this link for some info
www.datafocus.com/docs/man1/rexec.1.asp


-Original Message-
Sent: Thursday, February 22, 2001 7:36 PM
To: Multiple recipients of list ORACLE-L


Forgive me if this a stupid question and unrelated to Oracle but it pulls
data from an Oracle database and i hope one of you scripting gurus can help
me out  ;-)  It's on HP-UX 10.20.

I need to find a way within a script to handle a system generated prompt.
I'm trying to use the REXEC command to run a batch script on an NT machine
from UNIX.  I've got the NT side set up with REXECD.  When I run the REXEC
command from the UNIX prompt, it prompts me for a password (for
authentication on the NT machine I suppose).  How do I script this process
so I do not have to manually type in the password?  Here's the command:

rexec nt_machine -l user e:\\top_dir\\ev00_07\\run\\batch_script.bat

after I run it, it prompts for a password; if I type the NT password in for
the user, it works fine, so the syntax of the command is correct.  I just
want to automate this so I can schedule it instead of typing in the password
manually.

I know I can use RSH instead and not worry about authentication, but the
administrative overhead to get that implemented (security worries, etc)
would carry me through to retirement age.  I'm sure there is a simple way to
do this, but I'm not seeing it.   I try not to bother the list with
questions if I can help it, but I'm stuck on this one and don't want to
throw in the towel.

Thanks!


John Dailey
Consultant
Concept Solutions, LLC
*Your Business Intelligence Partner*
www.concept-solutions.com


--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: John Dailey
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: hp
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: John Dailey
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



RE: Shell scripting question

2001-02-23 Thread hp

check out this link for some info
www.datafocus.com/docs/man1/rexec.1.asp


-Original Message-
Sent: Thursday, February 22, 2001 7:36 PM
To: Multiple recipients of list ORACLE-L


Forgive me if this a stupid question and unrelated to Oracle but it pulls
data from an Oracle database and i hope one of you scripting gurus can help
me out  ;-)  It's on HP-UX 10.20.

I need to find a way within a script to handle a system generated prompt.
I'm trying to use the REXEC command to run a batch script on an NT machine
from UNIX.  I've got the NT side set up with REXECD.  When I run the REXEC
command from the UNIX prompt, it prompts me for a password (for
authentication on the NT machine I suppose).  How do I script this process
so I do not have to manually type in the password?  Here's the command:

rexec nt_machine -l user e:\\top_dir\\ev00_07\\run\\batch_script.bat

after I run it, it prompts for a password; if I type the NT password in for
the user, it works fine, so the syntax of the command is correct.  I just
want to automate this so I can schedule it instead of typing in the password
manually.

I know I can use RSH instead and not worry about authentication, but the
administrative overhead to get that implemented (security worries, etc)
would carry me through to retirement age.  I'm sure there is a simple way to
do this, but I'm not seeing it.   I try not to bother the list with
questions if I can help it, but I'm stuck on this one and don't want to
throw in the towel.

Thanks!


John Dailey
Consultant
Concept Solutions, LLC
*Your Business Intelligence Partner*
www.concept-solutions.com


-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: John Dailey
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: hp
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).



Re: Shell scripting question

2001-02-23 Thread Thater, William

On Thu, 22 Feb 2001,John Dailey scribbled on the wall in glitter crayon:


->so I do not have to manually type in the password?  Here's the command:
->
->rexec nt_machine -l user e:\\top_dir\\ev00_07\\run\\batch_script.bat

have you tried:
rexec nt_machine -l user e:\\top_dir\\ev00_07\\run\\batch_script.bat << !!
password
!!

this works in ksh for sure, in bash i think and may work in sh too, but i don't
use sh that often.  note that the !! *MUST* start in position 1 and be on a line
by itself.

--
Bill Thater Certified ORACLE DBA
Telergy, Inc.[EMAIL PROTECTED]
~
You gotta program like you don't need the money,
You gotta compile like you'll never get hurt,
You gotta run like there's nobody watching,
It's gotta come from the heart if you want it to work.
~
There are always at least two ways to program the same thing.

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Thater, William
  INET: [EMAIL PROTECTED]

Fat City Network Services-- (858) 538-5051  FAX: (858) 538-5051
San Diego, California-- Public Internet access / Mailing Lists

To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).