formatting a shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting formatting a shell script
# 1  
Old 05-03-2012
formatting a shell script

there is one shell which calls for different sql scripts.
output of different are formatted in frame like structure.i want columnar wise formatting to be done in such a manner that output of one sql may be comon input of rest sqls .
Code:
ERC  DML
  Closure  Date
  ER  DML
  SAP Transfer  Date
   
  APL  DML
  Release  Date
  JP  DML
  SAP Transfer  Date
    07JM200193   
  23/04/2012
  07JM200193ER
  23/04/2012
   
  07JM200193_APL
  25/04/2012
  07JM200193JP
  25/04/2012



Code:
          #!/bin/sh
        # erc.log :-    ERC DML output
        # apl.log:-     APL DML output
        # apl_task.log :-APL Planner output
        # jp.log:-      JP Loding output
        # ER.log:-      ER loading output
        # final_mail.sh = sap_header.txt + report.log + sap_footer.txt
       export ORACLE_HOME=/user/oraclnt/8.1.7
        export ORACLE_SID=PLMJD
        export DB_VENDOR=ORA
        export LOCAL=PLMJD
        export TWO_TASK=PLMJD
        export VC_HOSTNAME=plmjox01
        export PATH=/user/oraclnt/8.1.7/bin:/usr/bin:/usr/java2/bin:/sbin:/user/cmitc4/bin:.:/misc/plmclient/bin:$PATH
        export LD_LIBRARYN32_PATH=/user/oraclnt/8.1.7/lib32:$MTI_ROOT/bin:/usr/java2/lib32/sgi
        export OPNLDFLAGS='-O -L/user/oraclnt/8.1.7/lib32'
        export ORALIBS=/user/oraclnt/8.1.7/lib32/libclntsh.so.8.0
        export LOCATION="/user/omfprod/archana/sap_notification"
        final_mail=$LOCATION/final_mail.sh
        cd $LOCATION
        $LOCATION/erc.sql "$1" "$2"                       >erc.log
        echo ""
        echo "* * * * * * * * * * * ERC DML Ends * * * * * * *" >>erc.log
        :>apl.log
        for line in `cat erc.log|grep -i "erc"|awk '{print $1}'`
        do
             $LOCATION/apl.sql $line                       >>apl.log
        done
        echo
        echo "* * * * * * * * * APL  DML Ends * * * * * * * * *" >>apl.log
        :>apl_task.log
        for line in `cat erc.log|grep -i "erc"|awk '{print $1}'`
        do
                $LOCATION/apl_task.sql $line                       >>apl_task.log
        done
        echo
        echo "* * * * * * * * * APL TASK FOR PLANNER Ends * * * * * * * * *" >>apl_task.log
        :>jp.log
        for line in `cat erc.log|grep -i "erc"|awk '{print $1}'`
        do
                $LOCATION/jp.sql $line                       >>jp.log
        done
        echo
        echo "* * * * * * * * * SAP LOADING OF JP DMLS * * * * * * * * *">>jp.log
        :>ER.log
        for line in `cat erc.log|grep -i "erc"|awk '{print $1}'`
        do
                $LOCATION/ER.sql $line                       >>ER.log
        done
        echo
        echo "* * * * * * * * * SAP LOADING OF ER DMLS * * * * * * * * *">>ER.log
       cat erc.log >report.log
        cat apl.log >>report.log
        cat apl_task.log >>report.log
        cat jp.log >>report.log
        cat ER.log>>report.log
        cat sap_header.txt >>$final_mail
        cat report.log   >>$final_mail
        cat sap_footer.txt >>$final_mail
        chmod 700 $final_mail
        $final_mail
        exit 0


Last edited by Scrutinizer; 05-03-2012 at 01:41 AM.. Reason: code tags and formatting, removal of spaces
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need some help in formatting answer of shell script

Dear all, I am new to shell scripting and have tried to make a small program for fun sake that tells age from the last number of cell phone and birth year. At the end we get a final 3 digit number and the first digit represents the last digit of cell phone and rest 2 numbers shows age. eg. 423... (4 Replies)
Discussion started by: stg44
4 Replies

2. Shell Programming and Scripting

Formatting a file using shell script

Hi, Please find the below lines of a file B1/OT "GIB10" 837 130308 1351 MONORONOUS DIGI PATH FAULT SUPER B1/OT "GIB10" 520 130418 1537 MONORONOUS DIGI PATH FAULT SUPER B1/XT "GIB10" 762 130421 0653 TV Y-CEIVER ADMIN RXOCF-62 241_OKEBOLE_NEW 1 B1/XT "GIB10" 385 130425 1931 TV Y-CEIVER... (2 Replies)
Discussion started by: Ardhendu
2 Replies

3. Shell Programming and Scripting

Formatting File Using Shell Script

Hi Team, We have a requirement where we need to format input file using shell script by meeting the below conditions. 1. 1. Ignore first 549 characters of that file. 2. 2. After that we need to make a file of 100 characters per line, repeat it until the 3rd ... (16 Replies)
Discussion started by: ataneja7
16 Replies

4. Shell Programming and Scripting

Formatting a file using shell script

I have a file with contents something similar to as below : SVCNAME,12m-1a,1a-2a,2a-3a,3a-4a,5a-6a,6a-7a,7a-8a,8a-9a,9a-10a,10a-11a,11a-12n,12n-1p,13p-14p,14p-15p,15p-16p,16p-17p,17p-18p,18p-19p,19p-20p,20p-21p,21p-22p,22p-23p,11p-12m, TOTALS... (5 Replies)
Discussion started by: deo_kaustubh
5 Replies

5. Shell Programming and Scripting

Formatting the query output using shell script

Hi All, I'm finding it difficult to format the query output that was returned in a shell script. Actually i have one shell script which does some DB stuff and depending on the result it will do some more tasks. My question here is to format the query output returned by mysql. Intitally my... (5 Replies)
Discussion started by: RSC1985
5 Replies

6. Shell Programming and Scripting

Date formatting in shell script

Hi, I am writing a script and I need to calculate last weeks date. I get the current date as; today=`date '+%Y%m%d'` and I need last week inthe same format. Thanks, (2 Replies)
Discussion started by: ozum
2 Replies

7. Shell Programming and Scripting

Help with shell script in formatting the records.

I have a text file in the following format. can any one please help me in printing the output in userfriendly format mentioned below. Input. 1) /ss/abc/1/w/s/domainname/abc1/logname/ ########error################### ########error################### ########error###################... (2 Replies)
Discussion started by: vinny81
2 Replies

8. Shell Programming and Scripting

formatting a file using shell script

Hi I have to do the following.I have to format a file test.t The contents are # Header 1231 xyz asdf asdapsdcsd //string1 = "pqrs" //string1 = "abcd"; //info //string1 = "*pqrs"; //add string1 = "#123"; //sub //string1 = "#1234567890" data = check(string1) //string1 = "#1234567890"... (12 Replies)
Discussion started by: gopsman
12 Replies

9. UNIX for Advanced & Expert Users

Date Formatting in Shell Script

Hi, Can anybody throw somelight on how to handle date in a shell script? I need to pass the date in this format 'yymmdd' and then pad it to a file. The way in which i've handled is given below, but the date is not getting passed rather the file is getting created with a null date. Any... (2 Replies)
Discussion started by: Isiva
2 Replies

10. Shell Programming and Scripting

Formatting lines in shell script

I have a file with the below lines 1521 1522 1523 1524 1525 1526 ... 174 lines all numbers like above. I want the above file to appear as below. 1521,1522,1523,1524..... All the numbers should be separated by comma. Pls tell me how to do this .... Thanks in advance. (8 Replies)
Discussion started by: dreams5617
8 Replies
Login or Register to Ask a Question