Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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:
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.