如何在Ubuntu上运行Perl脚本

时间:2018-11-11 09:01:59

标签: perl ubuntu

如何在Ubuntu上运行perl脚本? 如何执行这个指令码 https://zwitterion.org/software/aggregate-cidr-addresses/

我已经创建了示例中所示的文件aggregate-cidr-addresses。

我已经从服务器的同一目录中复制了文件

然后按照示例所示运行

root@Ubuntu:~$ list-iana-reserved-ranges | aggregate-cidr-addresses
list-iana-reserved-ranges: ukaz ni bil najden (translate command not found)
aggregate-cidr-addresses: ukaz ni bil najden (translate command not found)

还有

root@Ubuntu:~$ perl list-iana-reserved-ranges | aggregate-cidr-addresses
Number found where operator expected at list-iana-reserved-ranges line 2, near "192.168.1.0"
(Missing semicolon on previous line?)
syntax error at list-iana-reserved-ranges line 2, near "192.168.1.0"
Execution of list-iana-reserved-ranges aborted due to compilation errors.
aggregate-cidr-addresses: ukaz ni bil najden (translate command not found)

我有

command not found

如何正确运行?

1 个答案:

答案 0 :(得分:2)

要运行Perl脚本,

  • 将解释器放在文件的第一行中,并带有“ shabang”或“ hash bang”(#!),您链接到的脚本已经具有:

#!/usr/bin/perl

  • 使文件可执行:

chmod +x list-iana-reserved-ranges aggregate-cidr-addresses

  • 在文件名的开头添加./(这是一项Linux安全功能,不会在当前目录中意外运行脚本):

./list-iana-reserved-ranges | ./aggregate-cidr-addresses