如何通过命令行将 POST 和 GET 数据发送到 Perl CGI 脚本? [英] How can I send POST and GET data to a Perl CGI script via the command line?

查看:17
本文介绍了如何通过命令行将 POST 和 GET 数据发送到 Perl CGI 脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过命令行参数发送 get 或 post.那是在我通过浏览器测试之前在命令行中测试脚本(服务器有问题).我尝试在线搜索,我想我可能使用了不正确的术语,因为我一无所获.我知道这是可能的,因为我看到有人这样做了.我只是不记得它是如何完成的.

I am trying to send a get or a post through a command-line argument. That is test the script in the command line before I test through a browser (the server has issues). I tried searching online, and I suppose I was probably using incorrect terminology because I got nothing. I know this is possible because I saw someone do it. I just don't remember how it was done.

谢谢!:)

推荐答案

您使用的是标准 CGI 模块吗?

Are you using the standard CGI module?

例如,使用下面的程序(注意-debug在参数中use CGI)

For example, with the following program (notice -debug in the arguments to use CGI)

#! /usr/bin/perl

use warnings;
use strict;

use CGI qw/ :standard -debug /;

print "Content-type: text/plain

",
      map { $_ . " => " . param($_) . "
" }
      param;

您在命令行上为其提供参数:

you feed it parameters on the command line:

$ ./prog.cgi foo=bar baz=quux
Content-type: text/plain

foo => bar
baz => quux

您也可以通过标准输入这样做:

You can also do so via the standard input:

$ ./prog.cgi
(offline mode: enter name=value pairs on standard input; press ^D or ^Z when done)
foo=bar
baz=quux
^D
Content-type: text/plain

foo => bar
baz => quux

这篇关于如何通过命令行将 POST 和 GET 数据发送到 Perl CGI 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆