OXIESEC PANEL
- Current Dir:
/
/
home
/
cubot
/
bin
/
etl_odbc
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📄
-d
10 bytes
02/03/2023 07:34:13 AM
rw-r--r--
📁
..
-
02/03/2023 08:06:37 AM
rwxr-xr-x
📄
config.pl
7.61 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
cross2normal.pl
3.71 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
dataextract.sh
2.51 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
etl.pl
5.42 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
etlproc
9.99 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
func.pl
4.01 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
globvar.sh
127 bytes
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
initetl.pl
1.88 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
libawk.awk
3.07 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
makeXtab2NormalExcel.pl
5.73 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
process.pl
6.91 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
process_changed.pl
5.69 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
readwrite.pl
4.16 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
rxcsv.pl
7.94 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
rxdb.pl
11.06 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
rxfile.pl
4.68 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
rxsalesforce.pl
3.5 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
rxxml.pl
13.83 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
rxxml2.pl
4.18 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
sendmail.pl
1.06 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
sourcequery.pl
4.18 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
sql.pl
23.98 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
store.pl
7.97 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
tags
13.14 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
task.pl
33.48 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📁
test
-
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
userfunc.pl
5.05 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
valid.pl
3.64 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
workflow.pl
3.94 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
📄
xform.pl
2.62 KB
02/03/2023 07:34:13 AM
rwxr-xr-x
Editing: rxxml2.pl
Close
#!/usr/bin/perl require XML::XPath; use XML::XPath::XMLParser; #use warnings; require "config.pl"; require "rxcsv.pl"; #$RXXLS_DIR="/tmp/xldir/"; #write_xmldata2csv("/etl/xtdata/XML/PHPAUCTIONXL_USERS"); sub write_xmldata2csv{ my $dir = shift; my $stgxml = getdirname("$dir/"); my %xmlschema; my @xmltaglist = (); my $stgdir = "$RXXLS_DIR/XML$stgxml"; @xmltaglist = &readschema($stgdir, "$stgxml.fmt", \%xmlschema); foreach $d(@xmltaglist){ printlog($MAX, "=====$stgxml=== $d ========"); } processdir($dir, \%xmlschema, \@xmltaglist); } ######################################################################################## # getdirlist #write_xmldata2csv($dir, $fmtfile); sub getdirlist{ local $dir = shift; local $flag = shift; local @dirlist = (); local $DH; $G_ERRMSG = undef; opendir($DH, $dir) or $G_ERRMSG = $!; print( "Processing $flag == $dir\n"); return 'ERR' if defined $G_ERRMSG; local $ctr = 0; foreach $name (readdir($DH)){ next if $name =~ /^\./; #Ignoring all files statring with . if($flag eq "D"){#Only Directories $dirlist[$ctr++] = $name if -d "$dir/$name"; } elsif ($flag eq "F"){#Only Files $dirlist[$ctr++] = $name if not -d "$dir/$name"; } else{#All Files & Dirs $dirlist[$ctr++] = $name; } } closedir($DH); return \@dirlist; } #################################### ONLY XML SCHEMA RELATED FUNCTIONs WILL BE IN THIS BLOCK ################################ sub readschema{ my $dir = shift; my $fmt = shift; my $xmlschema = shift; my @child; my @root; printlog($MAX, "Using dir=$dir and Mask=$fmt"); $G_ERRMSG = undef; #<-- Open Schema --># open(FP, "$dir/$fmt") or printlog($ERROR, "$G_ERRMSG = $!); print($ERROR, "$dir/$fmt.fmt failed : $G_ERRMSG") if defined $G_ERRMSG; printlog($ERROR, $G_ERRMSG) and return 'ERR' if defined $G_ERRMSG; my @tags = (); my @xmltaglist = (); my $ix = 0; while(my $readline = <FP>){ my $schema = ''; next if ($readline !~ m/^DATA/gs); chomp($readline); @tags = getxmltags($readline, \$schema, \$xtag); $line = ''; $line = $tags[$#tags]."[".$schema."]"; &getschema($line , \@root, \@child); foreach my $taglist(@child){ # $taglist = @child[0]; $$xmlschema{$xtag} = [ @$taglist ]; $xmltaglist[$ix] = $xtag; $ix++; } @root = (); @child = (); } close(FP); return @xmltaglist; } sub getschema{ my $str = shift; local *root = shift; local *child = shift; local $c = -1; local $r = -1; while(length($str)){ if($str =~ m/^[A-Z][A-Z0-9_]*[\[|:\]]/gsi){ } else{ $G_ERRMSG = "Error : Wrong Symbol found in schema parse string"; printlog($ERROR, "$G_ERRMSG"); return 'ERR'; } $str = $'; my $l = $&; $l =~ s/[\[|:|\]]//; if($& eq "["){ $root[++$r]=$l; $c = -1; } else{ $child[$r][++$c] = $l; } } } sub getxmltags { #my $str = "DATA2-/order/shipto/asd[strfnbr:stshnb]"; my $fmtline = shift; my $schema = shift; my $xtag = shift; my ($data, $tagline, $sch) = $fmtline =~ m/DATA([0-9]+)\-([^\[]+)\[([^\]]+)\]/gsi; $$schema = $sch; $$xtag = $tagline; my @xmltags = (); my $i = 0; my $st = ''; while($tagline ne ""){ my ($stag, $remtag) = $tagline =~ m/\/([^\/]+)(.*)/; $st = $st."/".$stag; $xmltags[$i] = $stag; $i++; $tagline = $remtag; } return @xmltags; } sub processdir{ my $xmldir = shift; my $xmlschema = shift; my $taglist = shift; local *xmldirfiles = &getdirlist($xmldir, "F"); foreach my $file(@xmldirfiles){ printlog($MAX, "Currently Processing file $xmldir/$file"); &processfile("$xmldir/$file", \%$xmlschema, \@$taglist); } } sub processfile{ my $file = shift; my $xmlschema = shift; my $taglist = shift; $xpath = XML::XPath->new(filename => $file) or $G_ERRMSG = "Can't Process XML File : $file"; return 'ERR' if defined $G_ERRMSG; foreach $root(@$taglist){ printlog($MAX, "Using $root as Root Node"); my $child = $$xmlschema{$root}; my $ch = 0; foreach $row($xpath->findnodes($root)){ foreach my $tag(@$child){ $data[$ch] = $row->find($tag)->string_value; $ch++; } $dt = join '|', @data; printlog($MAX, "$dt"); @data = (); } } } 1;