问题
A previous post might be useful: Perl system() call failed with return code 65280
Again, I've used this code many times, but it doesn't work here. I've moved all other perl instances from PATH.
Source:
$targetDir = "M\:\\bldforge_AOMS_DEV";
print ("targetDir=$targetDir\n");
chdir($targetDir) or die "Cant chdir to $dir $!";
$current_dir = `cd`;
print "\nCurrent dir = $current_dir\n"
Output:
Z:\>ccperl test.pl
targetDir=M:\bldforge_AOMS_DEV
Current dir =
回答1:
To be sure you are indeed in a ClearCase view, I would use cleartool pwd:
$current_dir = `cleartool pwd`;
That will work even on Windows:
The
cleartool pwd
command lists the current working directory.
This command is intended for use in interactive cleartool and multitool sessions, and in batch files or shell scripts that simulate interactive sessions.
回答2:
You are mixing up pwd
with cd
. cd
print only to STDERR, i.e. it succeeds silently.
My point is that cd
is of no use in your case.
回答3:
To get the current working directory, you should be using Cwd's getdcwd
function:
use Cwd;
my $current_dir = getdcwd 'M:';
来源:https://stackoverflow.com/questions/12006798/perl-chdir-doesnt-work