簡體   English   中英

無法將http請求標頭寫入perl中的文件

[英]Cant write http request headers to file in perl

我正在嘗試將HTTP標頭從請求寫入文件。 單獨執行的perl腳本可以正常運行並寫入文件。 但是,當我從http請求中調用腳本時,出現了HTTP 500錯誤,並且錯誤日志中顯示..“無法打開文件”,我評論了腳本中的“打開文件”行,並且從瀏覽器中調用時效果很好。 請告訴我我在這里做什么錯? 下面是代碼:

#!/usr/bin/perl  
use CGI qw(:standard); 
use strict; 
use warnings; 
use Carp; 
use LWP::Simple; 
my $query = CGI->new; 
my $file = '/home/suresh/clientrequest.txt'; 
chmod 644, $file; 
sleep(1); 
open my $flh, '+>>', "$file" or die "Cannot open file"; 
$flh->autoflush(); 
# Read the data here 
print $flh my @keywords = $query->keywords; 
print $flh $query->header(-domain=>'testdomain'); 
print $flh my @names= $query->param; 
close $flh; 
print header; 
print start_html("Welcome"); 
print $ENV{QUERY_STRING}; 
print end_html;

apache用戶尚未對該文件進行寫訪問。

為了獲得更好的錯誤消息,請更改此行:

open my $flh, '+>>', "$file" or die "Cannot open file"; 

open my $flh, '+>>', "$file" or die "Cannot open file '$file': $!"; 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM