Home: Perl Programming Help: Beginner:
"perl my.pl" is different from what i see from IE browser



ningji
User

Nov 12, 2012, 4:03 PM


Views: 7855
"perl my.pl" is different from what i see from IE browser

don't know how to describe it,
this is what i get from running from command line,

root@iSTAR000314:/opt/ultra/www# perl 3Diag.pl
Content-Type: text/html; charset=ISO-8859-1

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<title>why</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<h4>---------------------------</h4><h4>1</h4><h4>---------------------------</h4>
</body>
</html>



but in IE/firefox, i only see
------------------------
------------------------

not that "1"


(This post was edited by ningji on Nov 12, 2012, 4:04 PM)


ningji
User

Nov 12, 2012, 4:06 PM


Views: 7853
Re: [ningji] "perl my.pl" is different from what i see from IE browser

my simple code is here, very appreciated for your help.

#!/usr/bin/perl -w

BEGIN { push @INC, "/usr/share/perl5"; }
BEGIN { push @INC, "/usr/share/perl5/CGI"; }

use strict;
use warnings;
use CGI;
use CGI qw(:standard);

# new CGI form
my $q1 = new CGI;
my @backendCmd;

my @getCmd;
my @getLevel;
my $gpioLevel = 0;

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

# read from panel
@getCmd = `cd /opt/ultra/; showdata data/ACMClearanceDB.dbf 101 1 1`;
chomp($getCmd[0]);

@getLevel = split(/ {1,}/, $getCmd[0]);
$gpioLevel = $getLevel[0];

############################
print $q1->header();
print $q1->start_html(-title => 'why');

############################
print $q1->h4("---------------------------");
print $q1->h4($gpioLevel);
print $q1->h4("---------------------------");

print $q1->end_html;

exit 0;


ningji
User

Nov 12, 2012, 4:08 PM


Views: 7852
Re: [ningji] "perl my.pl" is different from what i see from IE browser

if you run
cd /opt/ultra/; showdata data/ACMClearanceDB.dbf 101 1 1

from command line, it gives you 5 digits, e.g.
1 2 3 4 5


rovf
Veteran

Nov 13, 2012, 2:09 AM


Views: 7837
Re: [ningji] "perl my.pl" is different from what i see from IE browser

If you view at the page source from your browser, what do you see then?


ningji
User

Nov 13, 2012, 7:15 AM


Views: 7833
Re: [rovf] "perl my.pl" is different from what i see from IE browser


In Reply To
If you view at the page source from your browser, what do you see then?


it's missing that 1,
<h4>---------------------------</h4><h4></h4><h4>---------------------------</h4>

very confusing.


rovf
Veteran

Nov 13, 2012, 7:22 AM


Views: 7831
Re: [ningji] "perl my.pl" is different from what i see from IE browser

This means that $gpioLevel is the empty string ('') in the error case .....

I fear you have to bite the bullet and debug, how this variable gets its value. My guess is that @getCmd doesn't contain what you expect (maybe it has one extra line in the beginning?), so I would first dump this variable:


Code
use Data::Dumper qw(Dumper); 

....
print $q1->h4(Dumper(\@getCmd));



ningji
User

Nov 13, 2012, 7:26 AM


Views: 7830
Re: [rovf] "perl my.pl" is different from what i see from IE browser

Rovf,

if i run "perl my.pl" from command line,
i do see that 1.
this is why i get confused, :(


In Reply To
This means that $gpioLevel is the empty string ('') in the error case .....

I fear you have to bite the bullet and debug, how this variable gets its value. My guess is that @getCmd doesn't contain what you expect (maybe it has one extra line in the beginning?), so I would first dump this variable:


Code
use Data::Dumper qw(Dumper); 

....
print $q1->h4(Dumper(\@getCmd));




rovf
Veteran

Nov 13, 2012, 8:01 AM


Views: 7829
Re: [ningji] "perl my.pl" is different from what i see from IE browser


Quote
if i run "perl my.pl" from command line,
i do see that 1.


... and that's why you have to debug it via the browser.


FishMonger
Veteran / Moderator

Nov 13, 2012, 9:28 AM


Views: 7820
Re: [ningji] "perl my.pl" is different from what i see from IE browser

The most likely problem is that the user that the web server is running under does not have rights to access or execute showdata.

Did you check the web server error log for any clues?


ningji
User

Nov 13, 2012, 1:26 PM


Views: 7811
Re: [FishMonger] "perl my.pl" is different from what i see from IE browser

got it finally,
i need to put the full path to that "showdata".

this is the 2nd time i forget this.
thanks for all the help !