开发者

firefox ("$linkurl"); problem

can anyone tell me why firefox is not opening up with the below Net::HTTPServer lines added?

#!/usr/bin/perl
# v5.10.1 / linux
use strict;
use warnings;
use Shell;
use Net::HTTPServer;


############ section ###############
my $server = new Net::HTTPServer(
                                 port=>5000,
                                 docroot=>"/home/frank/Perl/perl_info_pages",
                                 log => "/home/frank/Perl/perl_info_pages/access.log",

                                 chroot => 0,        #       - Run the server behind a virtual chroot().
                                #  Since only root can actually call chroot,
                                #  a URL munger is provided that will not
                                #  allow URLs to go beyond the document root
                                #  if thi开发者_JAVA百科s is specified.
                                #   ( Default: 1 )  / true ???

                                # allow only for localhost... and user ***
                                # super server daemon control of??
                                # cgi...
                                  );

$server->Start();
$server->Process(); 
 ############# end of section ###################

 # can anyone tell me why these lines work(to open up firefox) with the above section commented out, but do not work when they are uncommented??
my $linkurl = 'http://localhost:5000';
firefox ("$linkurl");


As explained into the HttpServer documentation, the Process() call is blocking and runs the server indefinitely, so the last two lines are never reached.

The simplest thing you could do is to spawn the Firefox process between the Start and the Process: the socket will be already created, and when the process spawning code will have returned the server will start running.


Net::HTTPServer's Process method never returns unless you give it a timeout. If you want to print a message, you have to do it before calling Process. You can do it after Start if you want to know what port the server has bound to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜