Compare commits
12 Commits
e4f62ea960
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| ef4fabca55 | |||
| e0eb5d8734 | |||
| f8b51c39ac | |||
| d6650839bc | |||
| c9d5d8b2fc | |||
| f0bf337cfb | |||
| 73295f8ac5 | |||
| 0024c2e65a | |||
| ff3da9be7f | |||
| a5292ae9cb | |||
| 21bb06f565 | |||
| 6d77fc7031 |
@@ -17,7 +17,7 @@ my $username = 'ase_lar';
|
||||
my $password = 'laravel';
|
||||
my $db_lar = 'ase_lar';
|
||||
my $db_sp = 'ase_lar';
|
||||
my $server = '80.211.107.201';
|
||||
my $server = 'localhost';
|
||||
my $db_name = "ase_lar";
|
||||
my $table = "RAWDATACOR";
|
||||
my ( @CSVData, @sql );
|
||||
@@ -28,8 +28,9 @@ my (
|
||||
$tool, $toolbatt, $tooltemp, $tooltype, @channels,
|
||||
@NewData, @ain, @din, @nodetype, $GDEventDate
|
||||
);
|
||||
my $matlab_proxy_ssh = "80.211.107.201";
|
||||
my $matlab_proxy_ssh_port = 2222;
|
||||
my $matlab_proxy_ssh = "localhost"; #"80.211.107.201";
|
||||
my $matlab_proxy_ssh_port = 22; #2222;
|
||||
my $matlab_exec_user = 'asega';
|
||||
my $matlab_cmd = "";
|
||||
my $matlab_timestamp = "";
|
||||
my $ftp_send = 1;
|
||||
@@ -43,7 +44,7 @@ my $duedate = '';
|
||||
my ( $unit_id, $unit, $unittype );
|
||||
my ( $fileDate, $fileTime );
|
||||
my $matlab_rt = "/usr/local/MATLAB/MATLAB_Runtime/v93";
|
||||
my $matlab_func_dir = "/mnt/elab-storage";
|
||||
my $matlab_func_dir = "/usr/local/matlab_func/";
|
||||
my $matlab_error = '';
|
||||
my $matlab_timeout = '1800';
|
||||
my $email_addr =
|
||||
@@ -53,9 +54,11 @@ my ( $email_msg, $email_obj );
|
||||
my $G201_fcheck = 0;
|
||||
my $D2W_fcheck = 0;
|
||||
my $G301_fcheck = 0;
|
||||
my $CR1000X_fcheck = 0;
|
||||
my $FtpToCustomerCmd = 'SendFtpElabData.pl';
|
||||
my ( $scriptname, $scriptpath );
|
||||
my $MatlabErrorFilename = "/mnt/elab-error";
|
||||
my $MatlabErrorPath = "/tmp/";
|
||||
my $MatlabErrorFilename = $MatlabErrorPath;
|
||||
my @matlabOutputErrorArray;
|
||||
my @errors;
|
||||
my @warnings;
|
||||
@@ -135,15 +138,17 @@ sub matlabCalc {
|
||||
#print $ENV{"HOME"} . "\n";
|
||||
$ENV{"HOME"} = "/" . $ENV{"HOME"};
|
||||
|
||||
my $cmd_elab =
|
||||
"timeout $matlab_timeout $matlab_cmd $matlab_rt $unit $tool";
|
||||
|
||||
#my $args = "sh -c \'cd $matlab_func_dir; pwd; $cmd_elab\'";
|
||||
|
||||
my $args =
|
||||
"ssh $matlab_proxy_ssh -p $matlab_proxy_ssh_port \"sh -c \'cd $matlab_func_dir; $cmd_elab\'\"";
|
||||
chdir($matlab_func_dir)
|
||||
or die "cannot change: $!\n";
|
||||
print getTimeStamp("log")
|
||||
. " - pid $$ >> current dir: $matlab_func_dir\n";
|
||||
my $args = "timeout $matlab_timeout $matlab_cmd $matlab_rt $unit $tool";
|
||||
|
||||
if ( system($args) != 0 ) {
|
||||
my $argscat =
|
||||
"cd $MatlabErrorPath; cat _${unit}_${tool}*_\*_output_error.txt > ${unit}${tool}_output_error.txt";
|
||||
system($argscat);
|
||||
|
||||
open( my $fh, '<', $MatlabErrorFilename )
|
||||
or warn print getTimeStamp("log")
|
||||
. " - pid $$ >> Cannot open Matlab output error file: ${MatlabErrorFilename}\n";
|
||||
@@ -449,7 +454,9 @@ elsif ( $filecsvname =~ m/^(\d*_|)(G301_ID\d\d\d\d_DT\d\d\d\d_\d*)$/i ) {
|
||||
}
|
||||
|
||||
while ( my $line = <FILE> ) {
|
||||
if ( $line =~ m/\A [[:ascii:]]* \Z/xms ) {
|
||||
|
||||
#if ( $line =~ m/\A [[:ascii:]]* \Z/xms ) {
|
||||
if ( $line !~ /\x00/ ) {
|
||||
$line =~ tr /\,/\;/ if ( $line =~ m/^\"\d\d\d\d.*/i ); #CR1000X
|
||||
$line =~ s/\"//g;
|
||||
my ( $first, $NodeData ) = split( /;/, $line, 2 );
|
||||
@@ -546,9 +553,6 @@ while ( my $line = <FILE> ) {
|
||||
elsif ( $tooltype eq "CR1000X" )
|
||||
{ # può essere tolto per attivarlo
|
||||
@CSVData = split( /\|/, $NodeData );
|
||||
print getTimeStamp("log")
|
||||
. " - pid $$ >> TEST CR1000X Execution ended.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
elsif ( $tooltype eq "MUSA" ) {
|
||||
|
||||
@@ -202,6 +202,27 @@ while ( my $line = $tail->GetLine() ) {
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
if ( ( $truser ne 'asega' ) and ( $truser ne 'corra' ) ) {
|
||||
print getTimeStamp("log")
|
||||
. " >> Sender user $truser: duplicate as asega user -> load data into DB.\n";
|
||||
my $realtruser = $truser;
|
||||
$truser = "asega";
|
||||
$outpath =~ s/$realtruser/$truser/;
|
||||
my ( $login, $pass, $uid, $gid ) = getpwnam($truser)
|
||||
or warn getTimeStamp("log")
|
||||
. " >> $truser not in passwd file.\n";
|
||||
unless ( fork() ) {
|
||||
setgid($gid);
|
||||
setuid($uid);
|
||||
$ENV{"HOME"} = 'home/' . $truser;
|
||||
exec( $scriptpath
|
||||
. "LoadCSVData.pl -f \"$dest\" -s \"$outpath/SQL/$filename"
|
||||
. "_"
|
||||
. "$timestamp.sql\" -d $truser >> /home/$truser/log/loadcsvdata.log 2>&1"
|
||||
);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user