amankhan
asked on
Need help with shell scripting...
Hi Guys,
I wrote a shell script. I want you guys to look at it and can give ur suggestions of how i can make it better. I am a starter and so needed ur help and assistance.
Help Appreciated.
Example Script:
==========
#!/bin/ksh
#
ORACLE_SID=IFSTEST; export ORACLE_SID
$ORACLE_HOME/bin/sqlplus -s apps/apps@$ORACLE_SID <<EOF
set echo off
set feedback off
set timing on
set termout off
set hea off
col FN format a45
set linesize 200
set pagesize 0
spool /usr/tmp/list.log
select outfile_name FN
from fnd_conc_requests_form_v
where program = 'AutoInvoice Print'
and argument1 = 'CUSTOMER'
and argument2 = 'INV'
and request_id = 4471022
and completion_text = 'Normal completion';
spool off
set timing off
exit
EOF
cd /usr/tmp
cat list.log | while read line
do
out_file=`echo $line | awk '{print $1}'`
cd /
lp -d PHSACT12 `echo $out_file`
rm list.log
done
========================== ========
Guys, I had one more question.
I am getting some data in to the list.log file, which is:
========================== ========== =======
old 7: and trunc(request_date) = to_date('&1','MM/DD/YYYY')
new 7: and trunc(request_date) = to_date('03/23/2006','MM/D D/YYYY')
/phsbay/IFSTEST/out/o44710 22.out
Elapsed: 00:00:07.95
========================== ========== =======
I am trying to extract the third line and print that file to the printer using lp -d printername filename
But what my problem is, its fetching every line and excuting it. First two lines and the fourth line also executes and displays " no such file or directory exists".
How can i supress them and take only the third line which is file showing the complete path where that file is stored.
Help Appreciated
Thanks
I wrote a shell script. I want you guys to look at it and can give ur suggestions of how i can make it better. I am a starter and so needed ur help and assistance.
Help Appreciated.
Example Script:
==========
#!/bin/ksh
#
ORACLE_SID=IFSTEST; export ORACLE_SID
$ORACLE_HOME/bin/sqlplus -s apps/apps@$ORACLE_SID <<EOF
set echo off
set feedback off
set timing on
set termout off
set hea off
col FN format a45
set linesize 200
set pagesize 0
spool /usr/tmp/list.log
select outfile_name FN
from fnd_conc_requests_form_v
where program = 'AutoInvoice Print'
and argument1 = 'CUSTOMER'
and argument2 = 'INV'
and request_id = 4471022
and completion_text = 'Normal completion';
spool off
set timing off
exit
EOF
cd /usr/tmp
cat list.log | while read line
do
out_file=`echo $line | awk '{print $1}'`
cd /
lp -d PHSACT12 `echo $out_file`
rm list.log
done
==========================
Guys, I had one more question.
I am getting some data in to the list.log file, which is:
==========================
old 7: and trunc(request_date) = to_date('&1','MM/DD/YYYY')
new 7: and trunc(request_date) = to_date('03/23/2006','MM/D
/phsbay/IFSTEST/out/o44710
Elapsed: 00:00:07.95
==========================
I am trying to extract the third line and print that file to the printer using lp -d printername filename
But what my problem is, its fetching every line and excuting it. First two lines and the fourth line also executes and displays " no such file or directory exists".
How can i supress them and take only the third line which is file showing the complete path where that file is stored.
Help Appreciated
Thanks
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.