A bit Complicate Script Required...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting A bit Complicate Script Required...
# 8  
Old 07-11-2007
Madhan...

As u said i have posted the Input and Output files

Can u have a look at those..

Been waithing for u from last 3 days Smilie
# 9  
Old 07-12-2007
Hi All

I was tring for Madhan but was not succesful...

I am using his perl script...

but there is somting not working it.. i have uploaded the latest input files

If any one can tell me whats to be changed in it..??
# 10  
Old 07-12-2007
You are not supposed to bump posts.


Coming to the question.

I asked for,

sample input and the output you expect and not the output that is obtained by running the script I had posted, which I could literally see that.

Please try to post, a sample input and the output you expect. Smilie
# 11  
Old 07-12-2007
Sorry for that madhan

the only chnage i have done in ur script is

#! /usr/bin/perl instead of #! /opt/third-party/bin/perl

Quote:
AAAAAA 01 FS-REC1.
BBBBBB 05 FS-KEY1.
10 FS-SOCT1 PIC 9(3) COMP-3.
D50180* 10 FS-GERA1 PIC 9(3) COMP-3.
D50180 10 FS-GER71 PIC 9(7) COMP-3.
10 FS-TIER1 PIC 9(7) COMP-3.
05 AS-CLI1 PIC X(10).
05 BS-CLI1 PIC X(10).

AAAAAA 01 FS-REC2.
BBBBBB 05 FS-KEY2.
10 FS-SOCT2 PIC 9(3) COMP-3.
D50180* 10 FS-GERA2 PIC 9(3) COMP-3.
10 FS-TIER2 PIC 9(7) COMP-3.
05 AS-CLI2 PIC X(10).
05 BS-CLI2 PIC X(10).


AAAAAA 01 FS-REC3.
BBBBBB 05 FS-KEY3.
D50180* 10 FS-GERA3 PIC 9(3).
10 FS-TIER3 PIC 9(7).
05 AS-CLI2 PIC X(10).
05 BS-CLI2 PIC X(10).


SORT FSORT ASCENDING KEY FS-KEY1
BS-CLI1
INPUT PROCEDURE INPUT-PROC


SORT FSORT ASCENDING KEY FS-KEY2
BS-CLI2
OUTPUT PROCEDURE OUTPUT-PROC.


SORT FSORT ASCENDING KEY FS-KEY3
USING PROCEDURE OUTPUT-PROC.
OUTPUT PROCEDURE OUTPUT-PROC.


SELECT FSORT ASSIGN SORTWK1.
* FICHIER SORT *
SD FSORT
* SORT PROCEDURE *
SORT FSORT ASCENDING KEY FS-KEY
IF SORT-RETURN NOT = ZERO
MOVE 'FSORT' TO FICH


I wanted the out put as followes


Quote:
AAAAAA 01 FS-REC1.
BBBBBB 05 FS-KEY1.
10 FS-SOCT1 PIC 9(3) COMP-3.
D50180* 10 FS-GERA1 PIC 9(3) COMP-3.
D50180 10 FS-GER71 PIC 9(7) COMP-3.
10 FS-TIER1 PIC 9(7) COMP-3.
05 AS-CLI1 PIC X(10).
05 BS-CLI1 PIC X(10).



AAAAAA 01 FS-REC2.
BBBBBB 05 FS-KEY2.
10 FS-SOCT2 PIC 9(3) COMP-3.
D50180* 10 FS-GERA2 PIC 9(3) COMP-3.
10 FS-TIER2 PIC 9(7) COMP-3.
05 AS-CLI2 PIC X(10).
05 BS-CLI2 PIC X(10).


AAAAAA 01 FS-REC3.
BBBBBB 05 FS-KEY3.
D50180* 10 FS-GERA3 PIC 9(3).
10 FS-TIER3 PIC 9(7).
05 AS-CLI2 PIC X(10).
05 BS-CLI2 PIC X(10).



SORT FSORT ASCENDING KEY
FS-SOCT1
FS-GERA1
FS-GER71
FS-TIER1

BS-CLI1
INPUT PROCEDURE INPUT-PROC


SORT FSORT ASCENDING KEY
FS-SOCT2
FS-GERA2
FS-TIER2

BS-CLI2
OUTPUT PROCEDURE OUTPUT-PROC.


SORT FSORT ASCENDING KEY
FS-GERA3
FS-TIER3

USING PROCEDURE OUTPUT-PROC.
OUTPUT PROCEDURE OUTPUT-PROC.


SELECT FSORT ASSIGN SORTWK1.
* FICHIER SORT *
SD FSORT
* SORT PROCEDURE *
SORT FSORT ASCENDING KEY FS-KEY
IF SORT-RETURN NOT = ZERO
MOVE 'FSORT' TO FICH

But when i run the script as follows

with input saved in "inp" .....

and say $ script.perl > out

the out file has the following

Quote:

AAAAAA 01 FS-REC1.
BBBBBB 05 FS-KEY1.
10 FS-SOCT1 PIC 9(3) COMP-3.
D50180* 10 FS-GERA1 PIC 9(3) COMP-3.
D50180 10 FS-GER71 PIC 9(7) COMP-3.
10 FS-TIER1 PIC 9(7) COMP-3.
05 AS-CLI1 PIC X(10).
05 BS-CLI1 PIC X(10).



AAAAAA 01 FS-REC2.
BBBBBB 05 FS-KEY2.
10 FS-SOCT2 PIC 9(3) COMP-3.
D50180* 10 FS-GERA2 PIC 9(3) COMP-3.
10 FS-TIER2 PIC 9(7) COMP-3.
05 AS-CLI2 PIC X(10).
05 BS-CLI2 PIC X(10).


AAAAAA 01 FS-REC3.
BBBBBB 05 FS-KEY3.
D50180* 10 FS-GERA3 PIC 9(3).
10 FS-TIER3 PIC 9(7).
05 AS-CLI2 PIC X(10).
05 BS-CLI2 PIC X(10).


SORT FSORT ASCENDING KEY
FS-SOCT1
FS-GERA1
FS-GER71
FS-TIER1
1
BS-CLI1
INPUT PROCEDURE INPUT-PROC


SORT FSORT ASCENDING KEY
FS-SOCT2
FS-GERA2
FS-TIER2
2
BS-CLI2
OUTPUT PROCEDURE OUTPUT-PROC.


SORT FSORT ASCENDING KEY
2
BS-CLI2
OUTPUT PROCEDURE OUTPUT-PROC.


SORT FSORT ASCENDING KEY
FS-GERA3
FS-TIER3
3
USING PROCEDURE OUTPUT-PROC.
OUTPUT PROCEDURE OUTPUT-PROC.


SORT FSORT ASCENDING KEY 1.
SORT FSORT ASCENDING KEY * FICHIER SORT
*
SORT FSORT ASCENDING KEY SD FSORT
SORT FSORT ASCENDING KEY * SORT PROCEDURE
*
SORT FSORT ASCENDING KEY SORT FSORT ASCENDING KEY FS-KEY
SORT FSORT ASCENDING KEY IF SORT-RETURN NOT = ZERO
SORT FSORT ASCENDING KEY MOVE 'FSORT' TO FICH



Am i doning something wrong????
# 12  
Old 07-12-2007
Code:
#! /opt/third-party/bin/perl

my %justHash = ();

open(FILE, "<", "inp") || die "Unable to open file inp <$!>\n";

while (<FILE>) {
  chomp;
  if( /FS-KEY/i ) {
    print "SORT FSORT ASCENDING KEY\n";
  }
  if( /sort/i ) {
    if( /^select/i ) {
      print "$_\n";
      next;
    }
    s/.*(\d+)/\1/;
    my @sub_arr = split(/\|/, $justHash{$_});
    foreach(@sub_arr) {
      s/(\d\d)(.*$)/\2/ if( /FS-/ );
      print "$_\n";
    }
  }
  print "$_\n";
  next if( /key(\d+)/i || /rec/i );
  if ( /FS-/ ) {
    s/PIC.*$//;
    s/^.* (\d\d)//;
    s/ //g;
    my $val = $_;
    s/.*(\d+)/\1/;
    $justHash{$_} = $justHash{$_} . "|" . $val;
  }
}

close(FILE);

exit 0

Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Which version of Windows Vista to install with a product key? 32-bit or 64-bit?

Hello everyone. I bought a dell laptop (XPS M1330) online which came without a hard drive. There is a Windows Vista Ultimate OEMAct sticker with product key at the bottom case. I checked dell website (here) for this model and it says this model supports both 32 and 64-bit version of Windows... (4 Replies)
Discussion started by: milhan
4 Replies

2. Shell Programming and Scripting

How to handle 64 bit arithmetic operation at 32 bit compiled perl interpreter?H

Hi, Here is the issue. From the program snippet I have Base: 0x1800000000, Size: 0x3FFE7FFFFFFFF which are of 40 and 56 bits. SO I used use bignum to do the math but summing them up I always failed having correct result. perl interpreter info, perl, v5.8.8 built for... (0 Replies)
Discussion started by: rrd1986
0 Replies

3. Red Hat

boot the 32 bit kernel on a 64 bit PPC Linux machine?

Hi all, I'm looking to cover a corner case for an upcoming test cycle. Is there a way to boot a RedHat Advanced Server 4 (update 3) installed on a Power PC machine to use a 32 bit kernel? This would be similar to what is done here -> https://www.unix.com/aix/26204-aix-platform.html I've done... (0 Replies)
Discussion started by: philrau
0 Replies

4. Programming

copying or concatinating string from 1st bit, leaving 0th bit

Hello, If i have 2 strings str1 and str2, i would like to copy/concatenate str2 to str1, from 1st bit leaving the 0th bit. How do i do it? (2 Replies)
Discussion started by: jazz
2 Replies
Login or Register to Ask a Question