LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-18-2008, 04:21 PM   #1
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Rep: Reputation: 39
Problem Getting A Perl Script to Run


Hi there --

I came across a perl script, start-debug.pl, that generates a GUI that is designed to interactively debug CGI programs. The script requires the Devel:tkdb package to be installed on the server that will contain the program. The script in question is shown below:

Code:
#!/usr/bin/perl -T
#
# Allows the administrator to debug a script by starting the
# interactive GUI debugger via an X session.
#
use strict;
use warnings;

$ENV{DISPLAY} = "localhost:0.0"; # Set the name of the display
$ENV{PATH}="/bin:/usr/bin:/usr/X11R6/bin";

system("/usr/bin/perl -T -d:ptkdb searcharchivedicom.cgi");
The file that is to be debugged by this script is the searcharchivedicom.cgi file.

The script is copied to the cgi directory, and then run at the localhost. The command syntax that is used is the following:

The problem is the following error messages appear on-screen instead of the GUI:

Quote:
"my" variable $state masks earlier declaration in same scope at /usr/local/apache2/lib//WebDB.pm line 534.
"my" variable $state masks earlier declaration in same scope at /usr/local/apache2/lib//WebDB.pm line 545.
"my" variable $clear masks earlier declaration in same scope at /usr/local/apache2/lib//WebDB.pm line 548.
"my" variable $state masks earlier declaration in same scope at /usr/local/apache2/lib//WebDB.pm line 568.
"my" variable $clear masks earlier declaration in same scope at /usr/local/apache2/lib//WebDB.pm line 634.
couldn't connect to display "localhost:0.0" at /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/Tk/MainWindow.pm line 55.
MainWindow->new() at /usr/lib/perl5/5.8.8/Devel/ptkdb.pm line 1147
Can't call method "setup_main_window" on unblessed reference at /usr/lib/perl5/5.8.8/Devel/ptkdb.pm line 4151.
END failed--call queue aborted.
What do the error message mean, and what do I need to do in order to get the script to work properly? Thanks.
 
Old 06-18-2008, 04:44 PM   #2
jpwigan
LQ Newbie
 
Registered: Jun 2008
Distribution: RHEL, Fedora, Gentoo, Slackware
Posts: 27

Rep: Reputation: 16
My guess is that this script expects to be run locally from the command line, not from a browser. It's trying to connect to your X server and is failing. Try executing:

/path/to/start-debug.pl

from a terminal. You may need to set it executable first:

chmod 755 /path/to/start-debug.pl
 
Old 06-18-2008, 04:52 PM   #3
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Original Poster
Rep: Reputation: 39
Hi there --

Thanks for your reply. I changed the permissions on the file to 755, and ran the script from the web browser and the command line. Unfortunately neither worked. Both generated the same error messages.
 
Old 06-18-2008, 09:43 PM   #4
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Hey There,

If you run it from the command line you might need to do

Quote:
export DISPLAY=10.10.10.10:0.0
<--- replace 10.10.10.10 with your local IP

based on

Quote:
couldn't connect to display "localhost:0.0"
and run

Quote:
xhost +
to help out if it's blocking.

Best wishes,

, Mike
 
Old 06-19-2008, 03:40 PM   #5
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Original Poster
Rep: Reputation: 39
Hi there --

Thanks for your reply. I tried the xhost + and export DISPLAY commands, but that approach didn't work.
 
Old 06-19-2008, 09:40 PM   #6
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Bummer,

Did you change this line in the script?

Quote:
$ENV{DISPLAY} = "localhost:0.0";
To your local IP when you ran it from the command line?

Also, could you post your errors after you made the changes. I'm sure that the -T is actually causing the script to fail because perl Taint won't allow you to use redefine a variable in the same scope.

Since you're using a script someone else wrote (or am I wrong on this), there may be nothing you can do but retool it. For instance, in the debug program, change the $state variable to $dstate (if that's not already taken). That would remove the same-scope same-variable redeclaration error, but may introduce others.

Best wishes to you,

Mike
 
Old 06-20-2008, 10:38 AM   #7
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Original Poster
Rep: Reputation: 39
Hi there --

Thanks for your reply. I made sure to insert the system's ip address in place of the local host. The error output that was generated after I reran the script is shown below:

Quote:
$ ./start-debug.pl
"my" variable $state masks earlier declaration in same scope at /usr/local/apache2/lib//WebDB.pm line 534.
"my" variable $state masks earlier declaration in same scope at /usr/local/apache2/lib//WebDB.pm line 545.
"my" variable $clear masks earlier declaration in same scope at /usr/local/apache2/lib//WebDB.pm line 548.
"my" variable $state masks earlier declaration in same scope at /usr/local/apache2/lib//WebDB.pm line 568.
"my" variable $clear masks earlier declaration in same scope at /usr/local/apache2/lib//WebDB.pm line 634.
couldn't connect to display "132.183.12.124:0.0" at /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/Tk/MainWindow.pm line 55.
MainWindow->new() at /usr/lib/perl5/5.8.8/Devel/ptkdb.pm line 1147
Can't call method "setup_main_window" on unblessed reference at /usr/lib/perl5/5.8.8/Devel/ptkdb.pm line 4151.
END failed--call queue aborted.
The script in question was written by someone else. I am new to perl programming so I have not ventured far into retooling the script.
 
Old 06-20-2008, 02:13 PM   #8
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Hey There,

It looks like scoping is the issue, but, maybe this is the root cause, or at least something I don't see asked and answered in the thread so far:

From the command line are you able to run any X-windows programs?

For instance, if you set

Quote:
host # DISPLAY=localhost:0.0
host # xhost +
host # startx (or any x-windows command)
Does that work? If it doesn't, that's definitely where we should focus next.

In the even that you've tried that already, can you point me to where you grabbed the script on the net and I can try it out on my machine?

Thanks

, Mike
 
Old 06-20-2008, 05:19 PM   #9
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Original Poster
Rep: Reputation: 39
Hi there --

I ran the xclock command from the command prompt, and it came back without a problem.

As far as the script is concerned, it came from the book "Wicked Cool Perl Scripts" by Steve Oualline. The script in question is the following: "#13 Debugging a CGI Program Interactively".

Listed below is the code in its original form:

Code:
1  #!/usr/bin/perl -T
2  #
3  # Allows you to debug a script by starting the
4  # interactive GUI debugger on your X screen.
5  #
6  use strict;
7  use warnings;
8
9  $ENV{DISPLAY} = ":0.0"; # Set the name of the display
10 $ENV{PATH}="/bin:/usr/bin:/usr/X11R6/bin:";
11
12 system("/usr/bin/perl -T -d:ptkdb hello.pl");
The idea behind this script is have a front-end GUI that will work with the Devel ptkdb debugger package.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
if you run perl, could you test this script: 2007fld Programming 1 07-20-2007 05:21 PM
how do I run a perl script in linux izquierdista Linux - Software 6 07-07-2007 10:54 PM
how to run a shell script in the perl script sharad Linux - General 1 05-24-2006 03:23 AM
How to run a perl script as a daemon ? paonethestar Programming 17 11-06-2003 08:53 PM
can't get perl script to run from www victorus Linux - General 0 03-27-2001 05:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration