richiamo matlab eseguibile linux

This commit is contained in:
2017-11-11 19:30:34 +01:00
parent 2edf0513b8
commit 74023ded8c
2 changed files with 29 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ use Getopt::Long;
use Net::FTP;
use List::Util qw( max );
use Data::Dumper qw(Dumper);
use Cwd;
$|++; # Autoflush
@@ -36,6 +37,8 @@ my $ftp_parm;
my $ftp_filename;
my $ftp_target;
my $unit_id;
my $matlab_rt = "/usr/local/MATLAB/MATLAB_Runtime/v93";
my $matlab_func_dir = "/usr/local/matlab_func/";
sub getTimeStamp
{ # parm [ts] => timestamp for filename; log => timestamp for log
@@ -104,12 +107,23 @@ sub matlabCalc {
getMatlabCmd();
$matlab_timestamp = getTimeStamp("db_ts");
print getTimeStamp("log") . " - pid $$ >> $tool MatLab calc started...\n";
my @out_matlab = `ssh1 $matlab_ip 'cmd /c $matlab_cmd ' $tool`;
print getTimeStamp("log")
. " - pid $$ >> $tool MatLab calc executed: $out_matlab[-1]";
#print getTimeStamp("log") . " - @out_matlab";
#print getTimeStamp("log") . " - pid $$ >> $out_matlab[-1]";
if ($matlab_cmd =~ /_lnx$/) {
$matlab_cmd = './run_' . $matlab_cmd . '.sh';
#print $ENV{"HOME"} . "\n";
$ENV{"HOME"} = "/" . $ENV{"HOME"};
chdir($matlab_func_dir)
or die "cannot change: $!\n";
my @args = ( $matlab_cmd, $matlab_rt, $tool);
system(@args) == 0
or die( getTimeStamp("log") . " - pid $$ >> system @args failed: $?\n" );
} else {
$matlab_cmd = 'matlab_' . $matlab_cmd . '.cmd';
my @out_matlab = `ssh1 $matlab_ip 'cmd /c $matlab_cmd ' $tool`;
print getTimeStamp("log")
. " - pid $$ >> $tool MatLab calc executed: $out_matlab[-1]\n";
#print getTimeStamp("log") . " - @out_matlab";
#print getTimeStamp("log") . " - pid $$ >> $out_matlab[-1]";
}
return;
}
@@ -309,13 +323,11 @@ sub getMatlabCmd {
. " - pid $$ >> No tool's matlab function selected.\n";
}
else {
my $mfunc;
while ( my $results = $sth->fetchrow_hashref ) {
$mfunc = uc $results->{'matcall'};
$matlab_cmd = $results->{'matcall'};
$ftp_send = $results->{'ftp_send'};
$unit_id = $results->{'unit_id'};
}
$matlab_cmd = 'matlab_' . $mfunc . '.cmd';
}
$sth->finish;

8
prova.pl Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper qw(Dumper);
chdir('/home/alex/Documenti');
system('dir');