Hello ,
Again,
problem with executing perl script from web .
I have fixed all my code and did not get any mestake with option perl -T
This perl script does not have any problem with executing from command
line :
perl -T smsgw.pl dest=5453 msgtxt=blabla

but when I try to made submit from web I get foloving $retval =65280 ,is
this some BUG or what?
Here is script called smsgw.pl

#!/usr/bin/perl -w
#===========================================================
# Program : smsgw.pl
# Author  : Philippe Andersson
# Date    : 24/03/99
# Version : 1.1
# Comment : (c) Les Ateliers du Heron, 1999 for Scitex Europe, S.A.
# Version History :
# * 1.0 (15/03/99) - Initial release.
# * 1.1 (24/03/99) - Fixed a problem with multi-line input.
#===========================================================
#-----------------------------------------------------------
# Name the global variables
my $dest = "";
my $msgtxt = "";
# Create en instance of CGI
my $query = new CGI;

# Send the MIME header
print $query->header ("text/html");
# Grab posted values
$dest = $query->param ("dest");
$msgtxt = $query->param ("msgtxt");            
# Was at least one field filled-in ?
if (($dest eq "") || ($msgtxt eq "")) {
  print $query->start_html (-title => "Greska !");
  print "<H1>Greska !</H1>\n";
  print "<P>Svi podaci su obavezni!";
  print $query->end_html;
  exit;
}   
# Check message length
my $txtlen = length ($msgtxt);
if ($txtlen > 160) {
  print $query->start_html (-title => "Error !");
  print "<H1>Error !</H1>\n";
  print "<P>Vasa poruka ne moze biti duza od 160 (char)karaktera
(now$txtlen). $
  print "Ovaj 160 char limit je ugraden u  SMS protocol i ne moze biti ";
  print "prekoracen ! ";
  print $query->end_html;
  exit;
}                                               
 # Remove newlines from msgtxt (replace them by space)
$msgtxt =~ s/\n/ /g;
#===========================================================
print $query->start_html (-title => "SMS Sending Rezultat");
print "<H1>SMS Sending Rezultat</H1>\n";
print "Poruka koju ste poslali glasi :  $msgtxt";
#-----------------------------------------------------------
# Submit the sendsms request
my $retval = 0;                           
if (($dest =~ /^([-\@\w.]+)$/) && ($msgtxt =~ /^([-\@\w.]+)$/)) {
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};   # Make %ENV safer
$ENV{"PATH"} = '/bin:/usr/local/bin:/usr/bin/';

$retval = system ("/bin/echo","$msgtxt","|
/usr/bin/gnokii/gnokii","--sendsms", "$dest"$
}
if ($retval == 0) {                                                   
print "<P>OK!!!</P>\n";
}
else {
  print "<P>Error.</P>\n";
  print $retval;
}

# End the HTML
#-----------------------------------------------------------
exit;                                                                     
                            

use strict;
use diagnostics;
use CGI;                              


Reply via email to