in reply to Re: How to pass variable values between perl scripts ?
in thread How to pass variable values between perl scripts ?
############################################################ #FIRST script: main_program.pl #!/usr/bin/perl use Getopt::Long; use Time::ParseDate qw(parsedate); use Time::Local; use POSIX qw(strftime); our ($GSX, $ASX, $TRACE, $SWITCHNAME, $FILENAME); GetOptions ( "g" => \$GSX, "a" => \$ASX, "t" => \$TRACE, "s=s" => \$SWITCHNAME, "f=s" => \$FILENAME ) or USAGE (); sub USAGE { print "USAGE: $0 -[ag] -f <filename>\n\n"; print "DESCRIPTION:\n"; print "\t -a : Defined ASX file type\n"; print "\t -g : Defined GSX file type\n"; print "\t -f : Assigned input file\n\n"; print "EXAMPLE:\n"; print "\t # $0 -a -f 1000001.ACT\n"; print "\t - Processed file name 10000001.ACT with ASX file type.\n +"; print "\n"; print "\t # $0 -g -f 1000001.ACT\n"; print "\t - Processed file name 10000001.ACT with GSX file type.\n +"; exit; } $SWITCHNAME = uc($SWITCHNAME); require "2.configuration_file.pl";
############################################################ #SECOND script: configuration_file.pl #!/usr/bin/perl use strict; use warnings; our $INPUTDIR = "/data/input"; our $ARBORCSTDIR = "/data/output/ARBOR"; our $ARBORCSVDIR = "/data/output/ARBORCSV"; our $RAWCSVDIR = "/data/output/RAWCSV"; our $FMSDIR = "/data/output/FMS"; our $INBILLDIR = "/data/output/INBILL"; our $ERRORDIR = "/data/error"; our $FILTERDIR = "/data/filter"; our $ARCHIVEDIR = "/data/archive"; our $DUPLICATEDIR = "/data/duplicate"; our $WORKDIR = "/data/work"; our $LOOKUPDIR = "/data/lookup";
############################################################ #THIRD script: open_file.pl #!/usr/bin/perl use strict; use warnings; sub CREATE_FILTER_HEADER { print (FILTER "FILTER CODE,STATUS,ANUM,BNUM,STARTDATE,DURATION,MBI +\n"); } sub CREATE_ERROR_HEADER { print (ERROR "ERROR CODE,STATUS,ANUM,BNUM,STARTDATE,DURATION,MBI\n +"); } sub CREATE INBILL_HEADER { my ($tmp); print (INBILL "VERSION = 2\n"); printf (INBILL "SWI_ID = %s\n", $swname); $tmp = substr($fname,1,6); $tmp =~ s/\0+//g; printf (INBILL "FILE_SEQ_NBR = %06s\n", hextoint($tmp)); printf (INBILL "TOTAL_RECS = %s\n", $total_records); print (INBILL "FIRST_DTTM = $firstdate\n"); print (INBILL "LAST_DTTM = $lastdate\n"); printf (INBILL "ORIG_FILE_NAME = %s\n", $inbill_fname); printf (INBILL "ORIG_FILE_VERSION = %s\n", "UNKNOWN"); printf (INBILL "CONVERTED_REC_STATS = %s:$total_records\n", "UNCAT +EGORIZED"); printf (INBILL "REJECTED_REC_STATS = %s:0\n", "UNCATEGORIZED"); printf (INBILL "DISCARDED_REC_STATS = %s:0\n", "UNCATEGORIZED"); printf (INBILL "ADDED_REC_STATS = %s:0\n", "UNCATEGORIZED"); printf (INBILL "ADD_DUP_CHK_KEY = %06s\n", hextoint($tmp)); printf (INBILL "GEN_FIELD_NAME_1 = %s\n", "C_PTY_NBR"); printf (INBILL "GEN_FIELD_NAME_2 = %s\n", "C_PTY_NBR_TYPE_ID"); printf (INBILL "GEN_FIELD_NAME_3 = %s\n", "ST_CODE"); printf (INBILL "GEN_FIELD_NAME_4 = %s\n", "MBI"); print (INBILL "\"REC_KEY\",\"ORIG_REC_KEY\",\"REC_TYPE_ID\",\"DUR_ +SPAN_ID\",\"CALL_START_DTTM\",\"PRE_CONV_DUR\","); print (INBILL "\"CONV_DUR\",\"A_PTY_NBR\",\"A_PTY_NBR_TYPE_ID\",\" +A_PTY_CELL_ID\",\"A_PTY_IMSI\",\"A_PTY_MSRN\","); print (INBILL "\"B_PTY_NBR\",\"B_PTY_NBR_TYPE_ID\",\"B_PTY_CELL_ID +\",\"B_PTY_IMSI\",\"B_PTY_MSRN\",\"IN_TRG_ID\","); print (INBILL "\"OUT_TRG_ID\",\"CALL_STATUS_ID\",\"SUPP_SVC_ID\",\ +"PROV_CHG_AMT\",\"GEN_FIELD_1\",\"GEN_FIELD_2\","); print (INBILL "\"GEN_FIELD_3\",\"GEN_FIELD_4\",\"GEN_FIELD_5\"\n") +; } sub CREATE_ARBOR_HEADER { my ($recType, $creation_dt, $rec_size, $num_record, $application, +$version, $data_record, $default); $recType = "HDR"; $creation_dt = strftime "%Y%m%d%H%M%S", localtime; $rec_size = "0000"; $num_record = "0000000"; $application = "NV2:MCS R3.0"; $version = "01.00"; $data_record = "TE3"; printf (ARBORCSV "%s,%s,%s,%s,%s,%s,%s,%s,%s\n", $recType, $creati +on_dt, $rec_size, $num_record, $application, $version, $data_record, +" ", " "); $recType = sprintf("%3s","HDR"); $creation_dt = sprintf ("%14s", strftime "%Y%m%d%H%M%S", localtime +); $rec_size = sprintf ("%s","0000"); $num_record = sprintf ("%s", "0000000"); $version = sprintf ("%5s", "01.00"); $data_record = sprintf ("%3s", "TE3"); $default = sprintf ("%12s", " "); printf (ARBORCST pack 'A3 A14 A4 A7 A16 A5 A3 A12 h1', $recType,$c +reation_dt,$rec_size,$num_record,"NV2:MCS R3.0",$version,$data_record +,$default,"A"); } sub CREATE_OUTPUT_FILE { my ($creation_dt, $tmpfile, $sw, $dt, $yy, $mm, $dd, $hh, $mi, $ss +); ($sw,$dt) = (split(/_/, $fname))[1,2]; ($yy,$mm,$dd,$hh,$mi,$ss) = (split(/-/, $dt))[0,1,2,3,4,5]; $creation_dt = "${yy}${mm}${dd}${hh}${mi}${ss}"; open (INPUT, "$INPUTDIR/$SWITCHNAME/$fname"); open (RAWCDR, "> $WORKDIR/$fname.csv"); $tmpfile = "${sw}.${creation_dt}.filter"; open (FILTER, "> $FILTERDIR/$SWITCHNAME$tmpfile"); CREATE_FILTER_HEADER(); $tmpfile = "${sw}.${creation_dt}.error"; open (ERROR, "> $ERRORDIR/$SWITCHNAME$tmpfile"); CREATE_ERROR_HEADER(); $tmpfile = sprintf ("%s.%s", $sw, $creation_dt); open (INBILL, "> $INBILLDIR/$SWITCHNAME$tmpfile"); CREATE_INBIL_HEADER(); $tmpfile = "${sw}.${creation_dt}.csa"; open (RAWCSV, "> $RAWCSVDIR/$SWITCHNAME$tmpfile"); $tmpfile = "${sw}.${creation_dt}.cst"; open (ARBORCSV, "> $ARBORCSV/$SWITCHNAME$tmpfile"); $tmpfile = "${sw}.${creation_dt}.data"; open (ARBORCST, "> $ARBORCST/$SWITCHNAME$tmpfile"); CREATE_ARBOR_HEADER(); $tmpfile = sprintf("CDR_${creation_dt}_${sw}_${creation_dt}.txt", +renameFMS($swname)); open (FMS, "> $FMSDIR/$SWITCHNAME$tmpfile"); } CREATE_OUTPUT_FILE();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to pass variable values between perl scripts ?
by NetWallah (Canon) on May 12, 2012 at 06:49 UTC |