6 окт. 2012 г.

LST to *.ireg

#!/usr/bin/perl

use Getopt::Std;
$config_path = '/usr/local/etc/';

open(LST,"L0010404A59F0.txt")|| die("Could not open config file!"); 

while ($_=) {
 if(!/^#/){
   @_=split('\t');
   $p0=uc(@_[0]);
   $p1=@_[1];
   $p2=@_[2];
   @_=split(',',$p2);
   $p10=@_[0];
   $p11=@_[1];
   $p12=@_[2];
   $p12=~tr/\n//d;
   $p13=@_[3];
   $p13=~tr/\n//d;
   $p14=@_[4];
   $p13=~tr/\n//d;
   open IREG,">>", $p1.".ireg";
   print  IREG "[general]\n";
   print  IREG "action = new\n";
   print  IREG "bankbranch = '001040'\n";
   print  IREG "template = '001040000000'\n";
   print  IREG "\n";                           
   print  IREG "[configuration]\n";
   print  IREG "terminalgroup = 'ПВН'\n";
   print  IREG "seniorcashierpwd = '123456'\n";
   print  IREG "\n";
   print  IREG "[terminal]\n";
   printf IREG "tid = '00%s'\n",$p1;
   printf IREG "merchantid = '%s'\n",$p1;
   print  IREG "accesspoint = 'INTERNET'\n";
   printf IREG "receiptheader-1 = '\\s\\b%s %s\\n'\n",$p13,$p14;
   printf IREG "receiptheader-2 = '\\w%s\\n'\n",$p10;
   printf IREG "receiptheader-3 = '\\w%s,\\n'\n",$p11;
   printf IREG "receiptheader-4 = '\\w%s\\n'\n",$p12;
   printf IREG "sslcertificatepem = '%s'\n",$p0;
   close IREG;
 }
}

# [general]
# action = new
# bankbranch = '001040'
# template = '001040000000'
# 
# [configuration]
# terminalgroup = 'ПВН'
# seniorcashierpwd = '123456'
# 
# [terminal]
# tid = '00628201'
# merchantid = '628201'
# accesspoint = 'INTERNET'
# receiptheader-1 = '\s\bФГУП ПОЧТА РОССИИ\n'
# receiptheader-2 = '682962 ОПС Шумный\n'
# receiptheader-3 = '\w с. Шумный\n'
# receiptheader-4 = '\w ул. Верхняя, 1\n'
# sslcertificatepem = '0010404A58BA.TLM'