Hi all,
i have here a nice problem.
I wrote a small gui for starting a perlscript. This script prints out the stuff which is defined in my gui.After that i write a file with the variables and start thru a QProcess a perlscript to process the data.
The problem is, that the perl script isnt working. If i comment out the open file, in the perlscript everything is ok.
Thanks for some hints..
Greetz
Below see my files.
mainwindow.ccp
void MainWindow::on_commandLinkButton_clicked()
{
//input variables
QString Variant = ui->inputVariant->text();
QString Load = ui->inputLoad->text();
//write file
QFile inputfile("/fs1/PerlQt/QtCreator/test/variables.inp");
inputfile.open(QFile::WriteOnly|QFile::Truncate|QFile::Text);
QTextStream str(&inputfile);
QStringList list;
list << Variant << Load ;
foreach(const QString &s, list)
{
str << s << endl;
}
//start perlscript
QProcess perl;
perl.start("./fs1/PerlQt/QtCreator/test/test.pl");
perl.waitForFinished(-1);
QString p_stdout = perl.readAllStandardOutput();
QString p_stderr = perl.readAllStandardError();
//output in textwindow
ui->output->setText(p_stderr);
ui->output->setText(p_stdout);
}
test.pl
#!/usr/bin/perl
#
sub print_var()
{
print "Name \n\n"; #print name
print "=> $files[0] \n"; #print the first entry in array files
}
open incl, 'variables.inp' or die "Datei nicht gefunden $!"; # open the file variables.inp
@files = <incl>; #read in file and fill a array @files
close(incl); #close file
print "agghagh \n\n"; #print stupid stuff
print_var(); #print the stuff which is in sub print_var
↧