Need help with shell scripting...

Posted on 2006-03-28
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 84

    Assisted Solution

    out_file=`head -3 list.log | tail -1`
    lp -d PHSACT12 $out_file
    LVL 29

    Accepted Solution


    In sqlplus command section code:

    set ver off
    set timing off

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
    Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
    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.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now