Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with perl scripts in web browsers

Status
Not open for further replies.

comoquieras

Programmer
Oct 24, 2000
3
ES
Hi all, I have a problem with a few perl scripts when I am using web browsers, such as Netscape 4.7 or Internet Explorer 5.5

The problem is as follows... when I follow a link in a form (or in a plain html page) to a perl script, sometimes a window pops up asking me if I want to save the perl script.
(of course, that's the only thing it allows me to do, I mean, I cannot run the perl script)

For example, when I follow a link with the following code:

<a HREF=&quot;/frontal/scripts/correo_nuevo.pl&quot; TARGET=&quot;_top&quot;>Correo</a>



Netscape asks me to save a file called correo_nuevo.exe (sometimes exe sometimes pl) with the following code:

<html>
<head>
<title>Correo</title>

</head>


<BODY>


<br>
</center>
</body>

<script language=javascript>
document.location = &quot;../usuarios/IGA051/fechlist.html&quot;
</script>

</html>


And nothing else happens.

This is part of the ASP code that builds the previous HTML code:

# servicios.pl
#
#

$nummaxmsg = 100;


$buzonesims = something
$buzoneshtm = something
$baseweb = something

$usuario = $ENV{AUTH_USER}; $usuario =~ s/^.*\\(.*)$/$1/;
$host=$ENV{SERVER_NAME};

### aqui se almacenan los enlaces a los logos en funcion del IdSer:


### comprobamos si hay mensajes sin convertir y en su caso redirigimos:
if (&mensajessinconvertir) {
print &quot;Location: $baseweb/scripts/comprobandomensajes.asp\n\n&quot;;
exit;
};


### obtenemos numero de mensajes sin leer:
$nummensajes = &nummensajessinleer;


use Win32::ODBC;

$dba = new Win32::ODBC(&quot;DSN=ssomething;UID=something;PWD=something&quot;);
if (!defined $dba) { die &quot;No se pudo abrir la base de datos (PC)&quot;; };

$dba->Sql(&quot;Select Config
from conrreo
where IdUsuario='$usuario'
&quot;);

$dba->FetchRow();
my $config = $dba->Data(&quot;Config&quot;);
print (&quot;Config= '$config' &quot;);

$dba->Close();

my $indicecorreo = (($config & 4)?'fech':'').(($config & 2)?'auto':'').(($config & 1)?'asun':'').'list.html';

#-------------------------------------------------------------------------
print <<END;
Content-Type: text/html

<html>
<head>
<title>Correo</title>

</head>


<BODY>


<br>
</center>
</body>

<script language=javascript>
document.location = &quot;../usuarios/$usuario/$indicecorreo&quot;
</script>

</html>
END
#-------------------------------------------------------------------------




##########################################################################

sub nummensajessinleer
{
my $convertidos = 0;

open(UIDLS, &quot;$buzoneshtm$usuario\\uidls.txt&quot;);
# || die(&quot;No se puede abrir el estado del correo HTML de '$usuario'&quot;);
while (<UIDLS>) { last if (/^;convertidos/); };
while (<UIDLS>) {
chop;
last if ($_ eq &quot;&quot;);
$convertidos++;
};
close(UIDLS);

return $convertidos;
}


sub mensajessinconvertir
{
my @listado, $uidls, $tmp;

### obtenemos directorio del buzon IMS -> @listado + @tmphash
if (! opendir(HANDLEDIR, &quot;$buzonesims$usuario&quot;)) {
print (&quot;No se puede abrir el directorio de correo IMS de '$usuario'&quot;);
return;
}
@listado = readdir(HANDLEDIR);
closedir(HANDLEDIR);
shift @listado; # quitamos '.'
shift @listado; # quitamos '..'
my @tmphash = reverse( sort(@listado) );
@listado = splice ( @tmphash, 0, $nummaxmsg );


open(UIDLS, &quot;$buzoneshtm$usuario\\uidls.txt&quot;);
# || die(&quot;No se puede abrir el estado del correo HTML de '$usuario'&quot;);
$uidls = join (&quot;&quot;, <UIDLS>);
close(UIDLS);

my $flag = 0;
foreach $tmp (@listado) {
$uidls =~ m/$tmp/ || do {
$flag = 1; goto FIN;
};
};

FIN: return $flag;

}


sub htmliza
{
$_ = shift;

#s//&Aacute;/g; # Á
#s//&Eacute;/g; # É
#s//&Iacute;/g; # Í
#s//&Oacute;/g; # Ó
#s//&Uacute;/g; # Ú
s/ß/&aacute;/g; # á
s/Ú/&eacute;/g; # é
s/Ý/&iacute;/g; # í
s/¾/&oacute;/g; # ó
s/·/&uacute;/g; # ú
#s//&Ntilde;/g; # Ñ
s/±/&ntilde;/g; # ñ
s/¬/&ordf;/g; # ª
s/¦/&uuml;/g; # ü

return $_;
}

1;





Any hints?

Thanks





[sig][/sig]
 
my first guess......

The problem is not in the browsers..... it is in the manner in which you are calling the Perl scripts. Your web browser should restrict the use of executable code (CGI stuff) to a specific place on the servers file system. That place usually has '...../cgi-bin/....' in it's path. Generally, if you want a script to execute (not print to the screen), you must put it where the web server expects to find executable CGI programs. If you put a Perl script in the 'document root' or one of it's sub directories, the web server should interpret a request for that document as a request for a static document, usually HTML. So, try putting the scripts in the cgi directory path.

' hope this helps.... [sig]<p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo[/sig]
 
Thanks for your answer, but I see a problem on it. I do not understand why those scripts work in some web brosers and don't in others. Is really curious, cause some always fail in the Explorer, and others fails in the Netscape.
So, I do not understand...

Thanks for all [sig][/sig]
 
It may be your headers. Do you return Content-type: text/html\n\n as the first line your output? If not, do so. IE, I think, assumes this, but Netscape will not parse the output as HTML unless you tell it to.

Otherwise, like GB suggested, I think it is most likely a permissions problem. You have to make your script executable both by the file system (chmod 775) and by the web server. The web server (in its configuration file) may or may not give you a specific directory where you can run scripts and it makes certain file extensions such as .cgi and .pl executable. It might make a difference because of how different web browsers request documents... one assuming a file will be returned, another requesting the output of the file.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
why those scripts work sometimes and sometimes doesn't work? Why in some web brosers and don't in others?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top