如何在.cgi脚本中调用.pl文件
我正在使用 CAM::PDF 中的 getpdftext.pl 来提取 pdf 并将其打印为文本,但在我的 Web 应用程序中,我想在 .cgi 脚本中调用此 getpdftext.pl 。你能建议我做什么或如何继续进行吗?我尝试将 getpdftext.pl 转换为 getpdftext.cgi 但它不起作用。
谢谢,
这是我的 request_admin.cgi 脚本的摘录
my $filename = $q->param('quote');
:
:
:
&parsePdf($filename);
#function to extract text from pdf ,save it in a text file and parse the required fields
sub parsePdf($)
{
my $i;
print $_[0];
$filein = "quote_uploads/$_[0]";
$fileout = 'output.txt';
print "inside parsePdf\n";
open OUT, ">$fileout" or die "error: $!";
open IN, '-|', "getpdftext.pl $filein" or die "error :$!" ;
while(<IN>)
{
print "$i";
$i++;
print OUT;
}
}
i am using getpdftext.pl from CAM::PDF to extract pdf and print it to text, but in my web application i want to call this getpdftext.pl inside .cgi script. Can u suggest me as to what to do or how to proceed ahead. i tried converting getpdftext.pl to getpdftext.cgi but it doesnt work.
Thanks all
this is a extract from my request_admin.cgi script
my $filename = $q->param('quote');
:
:
:
&parsePdf($filename);
#function to extract text from pdf ,save it in a text file and parse the required fields
sub parsePdf($)
{
my $i;
print $_[0];
$filein = "quote_uploads/$_[0]";
$fileout = 'output.txt';
print "inside parsePdf\n";
open OUT, ">$fileout" or die "error: $!";
open IN, '-|', "getpdftext.pl $filein" or die "error :$!" ;
while(<IN>)
{
print "$i";
$i++;
print OUT;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 CGI 脚本环境很可能
getpdftext.pl
和/或查看网络服务器的错误日志,看看它是否报告任何关于原因的指示不起作用。
It's highly likely that
getpdftext.pl
and/orHave a look in your web-server's error-log and see if it is reporting any pointers as to why this doesn't work.
在您的特定情况下,使用 CAM::PDF 直接,无论如何,它应该与
getpdftext.pl
一起安装。我查看了这个脚本,我认为您的
parsePdf
子文件可以轻松地编写为:In your particular case, it might be simpler and more direct to use CAM::PDF directly, which should have been installed along with
getpdftext.pl
anyway.I had a look at this script and I think that your
parsePdf
sub could just as easily be written as: