Sponsored Content
Full Discussion: quired output in form of
Top Forums Shell Programming and Scripting quired output in form of Post 302578563 by balajesuri on Friday 2nd of December 2011 12:31:12 AM
Old 12-02-2011
input.txt:
Code:
eventType communicationsAlarm,
eventTime "20111103164448",
loggingTime "20111103164549",
probableCause
lsname "VP2HPSGM01L3"
slCode = 5
eventType communicationsAlarm,
eventTime "20111103164448",
loggingTime "20111103164549",
probableCause slFailure,
lsname "VP2HPSHL01L3"
slCode = 6
eventType communicationsAlarm,
eventTime "20111103141027",
loggingTime "20111103141128",
probableCause
lsname "VP2HPSGM01L3"
slCode = 6
eventType communicationsAlarm,
eventTime "20111103141027",
loggingTime "20111103141128",
probableCause slFailure,
lsname "VP2HPSHL01L3"
slCode = 5
eventType communicationsAlarm,
eventTime
loggingTime "20111103141128",
probableCause slFailure,
lsname "VP2HPSHL01L3"
slCode = 14

Code:
#! /usr/bin/perl -w
use strict;

my (%x, @y);
my ($ln, $i) = (0, 1);

open INPUT, "< input.txt";
open OUTPUT, ">> output.txt";
print OUTPUT "eventType,eventTime,loggingTime, probableCause,lsname,slCode\n";
for $ln ( <INPUT> ) {
    if ($ln =~ /=/) {
        $ln =~ s/ = / /;
    }
    @y = split /\s+/, $ln;
    if ($#y == 0) {
        $y[1] = "NULL";
    }
    $y[1] =~ s/"//g;
    if ($y[1] !~ /,$/) {
        $y[1] =~ s/(\w+)/$1,/ unless ($y[1] =~ /^\d+$/);
    }
    print OUTPUT "$y[1]";
    if ($i == 6) {
        print OUTPUT "\n";
        $i = 0;
    }
    $i++;
}
close OUTPUT;
close INPUT;

output.txt:
Code:
eventType,eventTime,loggingTime, probableCause,lsname,slCode
communicationsAlarm,20111103164448,20111103164549,NULL,VP2HPSGM01L3,5
communicationsAlarm,20111103164448,20111103164549,slFailure,VP2HPSHL01L3,6
communicationsAlarm,20111103141027,20111103141128,NULL,VP2HPSGM01L3,6
communicationsAlarm,20111103141027,20111103141128,slFailure,VP2HPSHL01L3,5
communicationsAlarm,NULL,20111103141128,slFailure,VP2HPSHL01L3,14

 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Changing Unix form to Microsoft Word form to be able to email it to someone.

Please someone I need information on how to change a Unix form/document into a microsoft word document in order to be emailed to another company. Please help ASAP. Thankyou :confused: (8 Replies)
Discussion started by: Cheraunm
8 Replies

2. Shell Programming and Scripting

help on formatting output (Table Form)

Data in File ABC:DEFGHI:123 ABCZYE:DEFI:123 ABCFGD:DEF:123 ABCEERRRRR:DEFGHI:123 Expected Format 1 ABC DEFGHIFE 123 2 ABCZYE DEFI 123 3 ABCFGD DEF 123 4 ABCEERRRRR DEFGHI 123 However when i enter the following... (2 Replies)
Discussion started by: blurboy
2 Replies

3. UNIX for Advanced & Expert Users

How to parse through a file and based on condition form another output file

I have one file say CM.txt which contains values like below.Its just a flat file 1000,A,X 1001,B,Y 1002,B,Z ... .. total around 4 million lines of entries will be in that file. Now i need to write another file CM1.txt which should have 1000,1 1001,2 1002,3 .... ... .. Here i... (6 Replies)
Discussion started by: sivasu.india
6 Replies

4. Shell Programming and Scripting

need encrypt form

Hi, i need to encrypt and decrypt of a string. pls provide me some syntax or any method available using shell script. i know one method i.e., perl -e 'print pack "H*","message"' so if perl command doesnt work then what is the other method to encrypt and decrypt. Thanks in advance. (0 Replies)
Discussion started by: syamkp
0 Replies

5. Shell Programming and Scripting

Net::SSH::Perl->Execute any unix command & display the output in a proper form

Net::SSH::Perl ...... how to print the output in a proper format my $cmd = "ls -l"; my $ssh = Net::SSH::Perl->new($host); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd("$cmd"); print $stdout; the script works fine, but i am unable to see the output... (2 Replies)
Discussion started by: gsprasanna
2 Replies

6. Shell Programming and Scripting

Transpose Data form Different form

HI Guys, I have data in File A.txt RL03 RL03_A_1 RL03_B_1 RL03_C_1 RL03 -119.8 -119.5 -119.5 RL07 RL07_A_1 RL07_B_1 RL07_C_1 RL07 -119.3 -119.5 -119.5 RL15 RL15_A_1 RL15_C_1 RL15 -120.5 -119.4 RL16... (2 Replies)
Discussion started by: asavaliya
2 Replies

7. Shell Programming and Scripting

Remove x lines form top and y lines form bottom using AWK?

How to remove x lines form top and y lines form bottom. This works, but like awk only cat file | head -n-y | awk 'NR>(x-1)' so remove last 3 lines and 5 firstcat file | head -n-3 | awk 'NR>4' (5 Replies)
Discussion started by: Jotne
5 Replies

8. Shell Programming and Scripting

Displaying log file pattern output in tabular form output

Hi All, I have result log file which looks like this (below): from the content need to consolidate the result and put it in tabular form 1). Intercomponents Checking Passed: All Server are passed. ====================================================================== 2). OS version Checking... (9 Replies)
Discussion started by: Optimus81
9 Replies

9. Shell Programming and Scripting

Dispaying output in tabular form

hi, I have a script which is dispaying the output as below: Column 3:value1 Column 4:value 4 column 8:value 8 column 9:value 9 column 13:value 13 Column 3:value10 Column 4:value 40 column 8:value 80 column 9:value 90 column 13:value 103 However,I need the output in tabular... (5 Replies)
Discussion started by: Vivekit82
5 Replies
GAPPLETVIEWER(1)                                                        GNU                                                       GAPPLETVIEWER(1)

NAME
gappletviewer - Load and runs an applet SYNOPSIS
appletviewer [OPTION]... URL... appletviewer [OPTION]... -code CODE appletviewer [OPTION]... -plugin INPUT,OUTPUT DESCRIPTION
The appletviewer tool loads and runs an applet. Use the first form to test applets specified by tag. The URL should resolve to an HTML document from which the appletviewer will extract applet tags. The APPLET, EMBED and OBJECT tags are supported. If a given document contains multiple applet tags, all the applets will be loaded, with each applet appearing in its own window. Likewise, when multiple URLs are specified, each applet tag instance is given its own window. If a given document contains no recognized tags the appletviewer does nothing. appletviewer http://www.gnu.org/software/classpath/ Use the second form to test an applet in development. This form allows applet tag attributes to be supplied on the command line. Only one applet may be specified using the -code option. The -code option overrides the URL form -- any URLs specified will be ignored. appletviewer -code Test.class -param datafile,data.txt gcjwebplugin uses the third form to communicate with the appletviewer through named pipes. OPTIONS
URL OPTIONS -debug This option is not yet implemented but is provided for compatibility. -encoding CHARSET Use this option to specify an alternate character encoding for the specified HTML page. APPLET TAG OPTIONS -code CODE Use the -code option to specify the value of the applet tag CODE attribute. -codebase CODEBASE Use the -codebase option to specify the value of the applet tag CODEBASE attribute. -archive ARCHIVE Use the -archive option to specify the value of the applet tag ARCHIVE attribute. -width WIDTH Use the -width option to specify the value of the applet tag WIDTH attribute. -height HEIGHT Use the -height option to specify the value of the applet tag HEIGHT attribute. -param NAME,VALUE Use the -param option to specify values for the NAME and VALUE attributes of an applet PARAM tag. PLUGIN OPTION -plugin INPUT,OUTPUT gcjwebplugin uses the -plugin option to specify the named pipe the appletviewer should use for receiving commands (INPUT) and the one it should use for sending commands to gcjwebplugin (OUTPUT). DEBUGGING OPTION -verbose Use the -verbose option to have the appletviewer print debugging messages. STANDARD OPTIONS -help Use the -help option to have the appletviewer print a usage message, then exit. -version Use the -version option to have the appletviewer print its version, then exit. -JOPTION Use the -J option to pass OPTION to the virtual machine that will run the appletviewer. Unlike other options, there must not be a space between the -J and OPTION. BUGS
SEE ALSO
AUTHOR
0.98 2010-07-05 GAPPLETVIEWER(1)
All times are GMT -4. The time now is 09:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy