#!/usr/bin/perl # Copyright INRA # Sebastien.Carrere@toulouse.inra.fr # Jerome.Gouzy@toulouse.inra.fr # This software is a computer program whose purpose is to provide # a code generator framework for BioMoby web-services. # This software is governed by the CeCILL license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL # license as circulated by CEA, CNRS and INRIA at the following URL # "http://www.cecill.info". # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # In this respect, the user's attention is drawn to the risks associated # with loading, using, modifying and/or developing or reproducing the # software by the user in light of its specific status of free software, # that may mean that it is complicated to manipulate, and that also # therefore means that it is reserved for developers and experienced # professionals having in-depth computer knowledge. Users are therefore # encouraged to load and test the software's suitability as regards their # requirements in conditions enabling the security of their systems and/or # data to be ensured and, more generally, to use and operate it in the # same conditions as regards security. # The fact that you are presently reading this means that you have had # knowledge of the CeCILL license and that you accept its terms. =pod =head1 NAME PrintHello.pl - A test program who say hello and more =head1 SYNOPSIS PrintHello.pl --nicknames_file= --output_file= [--question] [--mobyle] [--user=],[--password= 'SecureWelcomeProgram', descr => "This program takes a list of nicknames as input and print a welcome sentence foreach one.It uses perl module Auth.pm to identify the user if provided, and modify output in consequence.", category => 'Service', #from BioMoby Service Type Ontology authors => 'Sebastien.Carrere@toulouse.inra.fr', cmd => abs_path($0), doclink => ['http://lipm-bioinfo.toulouse.inra.fr/biomoby'] ); my %h_appli_inputs = ( 'Nicknames' => { descr => "List of nicknames", namespace => '', #from BioMoby Namespace Ontology type_biomoby => 'List_Text', #from BioMoby Object Type Ontology cmd => '--nicknames_file=$value' } ); my %h_appli_outputs = ( 'WelcomeMessage' => { descr => "The resulting welcome message", namespace => '', #from BioMoby Namespace Ontology type_biomoby => 'text-formatted', #from BioMoby Object Type Ontology cmd => '--output_file=$value' } ); my ($dirprg, $nameprg) = $0 =~ /(.+)\/(.+)/; my %h_appli_parameters = ( 'a_question' => { descr => 'A question you want to ask for', type_biomoby => 'String', #String,Boolean,DateTime,Integer, Float default => '', cmd => '--question=\"$value\"' }, 'user' => { descr => 'Credential user', type_biomoby => 'String', #String,Boolean,DateTime,Integer, Float default => '', cmd => '--user=$value' }, 'password' => { datatype => 'password', #Mobyle type descr => 'Credential password', type_biomoby => 'String', #String,Boolean,DateTime,Integer, Float default => '', cmd => '--password=$value' } ); my $o_appli = New Appli(-general => \%h_appli_general); $o_appli->SetInputs(%h_appli_inputs); $o_appli->SetOutputs(%h_appli_outputs); $o_appli->SetParams(%h_appli_parameters); $o_param->SetAppli($o_appli); if ($o_param->IsDefined('mobyle')) { print STDOUT $o_appli->GetMobyleXml(); exit; } my ($dirprg, $nameprg) = $0 =~ /(.+)\/(.+)/; if ($o_param->IsDefined('pmbtest')) { print STDOUT $o_appli->GetPlaymobyTestXml(); exit; } $o_param->AssertFileExists('nicknames_file'); $o_param->AssertDefined('output_file'); my ($dirprg, $nameprg) = $0 =~ /(.+)\/(.+)/; my $htpassword_file = "$dirprg/etc/password"; my $authentified_user = 0; my $o_auth; if (-e $htpassword_file) { $o_auth = New Auth({ login => $o_param->Get('user'), password => $o_param->Get('password'), file => $htpassword_file, }); $authentified_user = $o_auth->CheckAuth(); } my $fh_nicknames = new IO::File($o_param->Get('nicknames_file')); die($!) if (!defined $fh_nicknames); my $fh_output = new IO::File('>' . $o_param->Get('output_file')); while (my $nickname = <$fh_nicknames>) { chomp $nickname; print $fh_output $o_auth->GetLogin . ' says : ' if ($authentified_user == 1); print $fh_output "Welcome $nickname! "; print $fh_output $o_param->Get('question') . '?' if ($o_param->IsDefined('question') && ($o_param->Get('question') ne '')); print $fh_output "\n"; } $fh_nicknames->close; $fh_output->close; }