CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



ningji
Novice

Nov 12, 2012, 4:03 PM

Post #1 of 10 (3660 views)
"perl my.pl" is different from what i see from IE browser Can't Post

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
Novice

Nov 12, 2012, 4:06 PM

Post #2 of 10 (3658 views)
Re: [ningji] "perl my.pl" is different from what i see from IE browser [In reply to] Can't Post

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
Novice

Nov 12, 2012, 4:08 PM

Post #3 of 10 (3657 views)
Re: [ningji] "perl my.pl" is different from what i see from IE browser [In reply to] Can't Post

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

Post #4 of 10 (3642 views)
Re: [ningji] "perl my.pl" is different from what i see from IE browser [In reply to] Can't Post

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


ningji
Novice

Nov 13, 2012, 7:15 AM

Post #5 of 10 (3638 views)
Re: [rovf] "perl my.pl" is different from what i see from IE browser [In reply to] Can't Post


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

Post #6 of 10 (3636 views)
Re: [ningji] "perl my.pl" is different from what i see from IE browser [In reply to] Can't Post

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
Novice

Nov 13, 2012, 7:26 AM

Post #7 of 10 (3635 views)
Re: [rovf] "perl my.pl" is different from what i see from IE browser [In reply to] Can't Post

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

Post #8 of 10 (3634 views)
Re: [ningji] "perl my.pl" is different from what i see from IE browser [In reply to] Can't Post


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

Post #9 of 10 (3625 views)
Re: [ningji] "perl my.pl" is different from what i see from IE browser [In reply to] Can't Post

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
Novice

Nov 13, 2012, 1:26 PM

Post #10 of 10 (3616 views)
Re: [FishMonger] "perl my.pl" is different from what i see from IE browser [In reply to] Can't Post

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 !

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives