如何编写Perl脚本以使用curl处理URL?

Duf*_*lan 10 perl cron curl crontab

我有一个非常简单的任务.我有一个crontab,每小时运行一个脚本.该脚本仅用于处理URL.

这就是我所拥有的.它不起作用.我收到语法错误.

#!/usr/bin/perl
curl http://domain.com/page.html;
Run Code Online (Sandbox Code Playgroud)

我多年没有在Perl工作过,而且在我做的时候并不是很熟练.

谢谢,Alex指出我正确的道路!

crontab中

*/30 * * * * curl http://domain.com/path.html
Run Code Online (Sandbox Code Playgroud)

小智 27

你可以使用curl反引号

my $curl=`curl http://whatever`
Run Code Online (Sandbox Code Playgroud)

或者你可以使用WWW::Curl.


Gre*_*ill 5

要从Perl调用任何shell命令,您可以使用system:

system "curl http://domain.com/page.html";
Run Code Online (Sandbox Code Playgroud)

只需将shell命令括在引号中即可.