The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Running command "md5" on remote host not working. ynilesh UNIX for Advanced & Expert Users 1 02-01-2008 04:15 AM
help: infinant loop script - host ping test zeekblack Shell Programming and Scripting 2 04-23-2007 03:11 AM
How to delete the files from local host to remote host krishna176 SUN Solaris 3 03-24-2007 12:48 PM
host alias not working: host not found FunnyCats UNIX for Advanced & Expert Users 4 05-13-2005 01:36 PM
QNX host cannot ping SCO host, vice versa gavon IP Networking 2 08-20-2001 05:57 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-09-2008
Registered User
 

Join Date: May 2008
Posts: 1
Stumble this Post!
host cp in ksh script not working

The following script is designed to backup the oracle control file to the trace directory and then copy (the trace file that was created by the backup command) and rename that file(to a .sql) to a backup disk. When I run the script from sqlplus as sysdba everything works but when I execute from command line the host cp command does not work.

What gives?


bk_control.ksh" 35 lines, 999 characters
#!/bin/ksh
ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_2
ORACLE_SID=FFITEST
PATH="$PATH:$ORACLE_HOME/bin"
export PATH ORACLE_HOME ORACLE_SID

sqlplus -S / as sysdba <<EOF >> /dev/null
set echo off feedback off verify off pages 0
column TRCLOC new_value TRCFILE
column TRCDATE new_value FILEDATE
column INSTNAME new_value INSTANCE
select to_char(sysdate, 'YYYYMMDD_HH24MISS') TRCDATE
from dual;
select instance INSTNAME
from v$thread;
alter database backup controlfile to trace;
select
c.value || '/' ||
lower(instance) || '_ora_' ||
ltrim(to_char(a.spid,'fm99999999')) ||
'.trc' TRCLOC
from
v$process a, v$session b,
v$parameter c, v$thread c
where
a.addr = b.paddr
and b.audsid = userenv('sessionid')
and c.name = 'user_dump_dest'
/
host cp &TRCFILE /svm/oracle/work/daily_export/control_&instance._&filedate..sql
exit
EOF
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-09-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,846
Stumble this Post!
move the copy command outside of sqlplus where most coders would expect to find it.
then you can use environment variables.

I also do not see how &TRCFILE &instance &filedate are passed to the script.
sqlplus requests the substitution when run from the command line like this:
Code:
SQL> select '&TRCFILE' from dual;
Enter value for trcfile: plpl
old   1: select '&TRCFILE' from dual
new   1: select 'plpl' from dual

'PLP
----
plpl

SQL> host cp &TRCFILE ~/t.lis
Enter value for trcfile: plpl
cp: cannot access plpl: No such file or directory
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:43 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0