Invoking dos command form Perl doesn’t work properly after installing Chef -
after installing chef on windows, found dos commands no longer work in perl if contain forward slashes. example, running `dir /ad .`
in perl give warning dir: /ad: no such file or directory
. know forward slash points root of current working directory of chef-client process. annoying affects perl well. there way fix this? thanks.
more info clarify issue: using clean win7 64bit machine activeperl 5.8.8 , chef client 11.12.2-1. issue related chef installation. first, on , off when install , uninstall chef client. second, when run dir /
, lists contents of c:\opscode\chef\embedded folder.
chef
isn't causing problems. system responds same command: my @dirs = `dir /ad .`
. treats /ad
directory instead of flag throwing same error message "dir: /ad: no such file or directory"
before returning all of files in current directory.
using mob's comment solution of my @dirs = `cmd /c dir /ad .`
fixes issue , returns list of directories desired.
however, best method solve issue make perl code cross-platform compatible not relying on os specific builtins. example, getting list of directories in cwd done using following:
my @dirs = grep -d, <*>;
update
i'm running strawberry perl 5.18.2 on windows 7 x64
c:\>perl -v perl 5, version 18, subversion 2 (v5.18.2) built mswin32-x64-multi-thread
given you've shared scope of task, think mob's solution best bet. yes, it'd pain have replace of backtick ``
, qx()
calls, don't foresee better option. luck figuring out if/how chef causing issue. don't have else add now.
Comments
Post a Comment