firefox(“$ linkurl”);问题

时间:2011-09-21 09:27:58

标签: linux perl

任何人都可以告诉我为什么firefox没有打开以下添加的Net :: HTTPServer行?

#!/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 this 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");

2 个答案:

答案 0 :(得分:1)

正如HttpServer文档中所解释的那样,Process()调用正在阻塞并无限期地运行服务器,因此永远不会到达最后两行。

您可以做的最简单的事情是在StartProcess之间生成Firefox进程:套接字已经创建,当进程生成代码返回时,服务器将启动运行。

答案 1 :(得分:1)

Net::HTTPServerProcess方法永远不会返回,除非你给它超时。如果要打印消息,则必须在调用Process之前执行此操作。如果您想知道服务器绑定的端口,可以在Start之后执行此操作。