#!/usr/bin/perl -w # This file name is: gettext_n_print.cgi use CGI qw/:standard :html3/; use CGI::Carp qw( fatalsToBrowser ); print header, start_html('Deploying Exec/System with CGI'), h1('Testing System/Exec function with CGI'); print_form() unless param; print_results_to_file() if param; print end_html; sub print_form { print start_multipart_form(), strong('Your text: '), textfield( -name => 'user_text' ), br, br submit(-label=>'Submit'), end_form; } sub print_results_to_file { my $param1 = param('user_text'); print "This text _should_ be printed to the file : ",br,br; print $param1,br; # But this system/exec call doesn't do the job? Why? system("perl prn_to_file.pl $param1 > ../results/output.txt"); # And these two also don't work # system("echo $param1 > ../results/output.txt"); # exec("perl prn_to_file.pl $param1 > ../results/output.txt"); # In actual practice I have to make several systems call for # a more complex perl script than just printing text like taking # output.txt as arg of another script like this: # system("perl other_code.pl output.txt > ../results/final.out2"); }