Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl 符号链接_Perl_Bash_Shell - Fatal编程技术网

Perl 符号链接

Perl 符号链接,perl,bash,shell,Perl,Bash,Shell,我创建了一个名为test.pl的文件 我更改了chmod u+x的权限模式: chmod u+x test.pl 我创建了一个指向它的符号链接: ln -s path/test.pl test 之后,我尝试运行测试,但它被解释为bash脚本。它给出了一个错误 您知道为什么吗?您的脚本必须有一行shebang,即包含要使用的解释器的第一行 #!/usr/bin/env perl #... your script content here. 所以外壳知道如何解释它 最佳实践是使用env来确定当

我创建了一个名为test.pl的文件

我更改了chmod u+x的权限模式:

chmod u+x test.pl
我创建了一个指向它的符号链接:

ln -s path/test.pl test
之后,我尝试运行测试,但它被解释为bash脚本。它给出了一个错误


您知道为什么吗?

您的脚本必须有一行shebang,即包含要使用的解释器的第一行

#!/usr/bin/env perl
#... your script content here.
所以外壳知道如何解释它

最佳实践是使用env来确定当前的perl版本,特别是在使用perlbrew或类似工具时,这些工具除了安装系统perl外,还安装了自己的perl。

test是一个内置命令

要在当前目录中执行名为test的命令,请指定相对或绝对路径:

$ ./test

此外,您还需要在脚本的第一行添加脚本,以便系统知道如何执行它。

您是否有相应的shebang eg/test.pl的第一行中的usr/bin/perl?