回复:https://stackoverflow.com/questions/23937389/determine-parent-shell-from-perl/25139489

时间:2019-01-31 20:09:11

标签: perl

有没有人尝试在Cygwin这个代码?

我得到这些错误:

Can't find string terminator "'" anywhere before EOF at -e line 1.
Use of uninitialized value in pattern match (m//) at ./dos_it.pl line 506.
Use of uninitialized value $shellpath in rindex at ./dos_it.pl line 586.
Use of uninitialized value $shellpath in substr at ./dos_it.pl line 586.
Use of uninitialized value $pathToShell in concatenation (.) or string at ./dos_it.pl line 761.
Use of uninitialized value $shell_conformance in concatenation (.) or string at ./dos_it.pl line 761.

生成的字符串是:

$ ps -ef | perl -ane '1..1 and /^(.*)CO?MM?A?N?D/ and $s=length $1;s/^.{$s}//; print "@F[1,2] $_"'

Perl版本:

$ perl -v    
This is perl 5, version 26, subversion 2 (v5.26.2) built for MSWin32-x64-multi-thread

1 个答案:

答案 0 :(得分:1)

这是Bourne shell(sh)或类似命令,但已将其交给Windows shell(cmd)执行。使用sh或类似的命令(无论是cygwin内置还是其他)执行命令以消除该错误。

顺便说一句,您使用的是Windows版本的Perl(MSWin32-x64拱),而不是Cygwin版本的Perl(cygwin拱)。这不是错误的原因,因为该程序可以正常运行。就是说,一旦您使用cygwin内置的sh或类似的命令执行命令,此“问题”肯定会消失。