separazione dell'ftp fissata

This commit is contained in:
2020-12-25 19:12:20 +01:00
parent d5bcd7988d
commit de8a7d1b92
2 changed files with 17 additions and 4 deletions

View File

@@ -24,7 +24,6 @@ my ( @CSVData, @sql );
my $outcount = 0;
my $outfilenum = 0;
my $maxsqllines = 10000;
my $csv_x_ftp_dir = '/home/asega/.csv_x_ftp';
my (
$tool, $toolbatt, $tooltemp, $tooltype, @channels,
@NewData, @ain, @din, @nodetype, $GDEventDate
@@ -52,6 +51,8 @@ my $from = 'ASE Alert System<alert@aseltd.eu>';
my ( $email_msg, $email_obj );
my $G201_fcheck = 0;
my $D2W_fcheck = 0;
my $FtpToCustomerCmd = 'SendFtpElabData.pl';
my ( $scriptname, $scriptpath );
sub getTimeStamp
{ # parm [ts] => timestamp for filename; log => timestamp for log
@@ -161,6 +162,15 @@ sub matlabCalc {
}
sub trxelab {
my $user = getpwuid($>);
my $ftpcmd = "$scriptpath$FtpToCustomerCmd -m \"$matlab_timestamp\" -u $unit -t $tool >> /home/$user/log/loadcsvdata.log 2>&1";
print getTimeStamp("log")
. " - pid $$ >> Fork FTP command to set GID mysql: $ftpcmd.\n";
exec('/usr/bin/sg', 'mysql', "$ftpcmd");
}
sub trxelab_old {
my $dbh =
DBI->connect( "DBI:mysql:$db_lar;host=$server", $username, $password )
or die getTimeStamp("log")
@@ -486,6 +496,8 @@ GetOptions(
open FILE, $filename
or die( "Error: opening input file " . $filename . "\n" );
( $scriptname, $scriptpath ) = fileparse($0);
if ( $db_name ne 'asega' ) {
$db_name =~ s/aseu/dbn/;
$db_sp = $db_name;

View File

@@ -48,7 +48,7 @@ sub trxelab {
my $sth = $dbh->prepare(
'select ftp_addrs, ftp_user, ftp_passwd, ftp_parm, ftp_filename, ftp_target, duedate from units
where name = ' . $unit . ';'
where name = "' . $unit . '";'
) or die getTimeStamp("log") . " - pid $$ >> $DBI::errstr";
$sth->execute();
@@ -120,8 +120,7 @@ sub trxelab {
my ( $key, $val ) = split( /=>/, $parm );
$ftp_parms{$key} = $val;
}
my $name = POSIX::cuserid();
print getTimeStamp("log") . " - pid $$ >> Current user id: $name\n";
print getTimeStamp("log")
. " - pid $$ >> $unit - $tool ftp parm:\n"
. Dumper(%ftp_parms);
@@ -184,6 +183,8 @@ GetOptions(
"tool=s" => \$tool
) or die("Error in command line arguments\n");
print getTimeStamp("log") . " - pid $$ >> Send via FTP elab data for $unit - $tool.\n";
if ( $tool eq 'DT0076' ) {
sleep(600);
}