Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Need help with shell scripting...

Posted on 2006-03-28
Medium Priority
Last Modified: 2013-12-26
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:
$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

cd /usr/tmp
cat list.log | while read line
out_file=`echo $line | awk '{print $1}'`
cd /
lp -d PHSACT12 `echo $out_file`
rm list.log

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/DD/YYYY')
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

Question by:amankhan
LVL 85

Assisted Solution

ozo earned 600 total points
ID: 16312486
out_file=`head -3 list.log | tail -1`
lp -d PHSACT12 $out_file
LVL 29

Accepted Solution

MikeOM_DBA earned 1400 total points
ID: 16312801

In sqlplus command section code:

set ver off
set timing off

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question