3

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 =
Community
  • 1
  • 1
Alex
  • 180
  • 2
  • 3
  • 10
  • Works (with `perl`) on my end - what is `ccperl`? – zb226 Aug 17 '12 at 13:38
  • @zb226: see my answer to user1288329's previous answer: http://stackoverflow.com/a/11992799/6309. This is about ClearCase (http://stackoverflow.com/tags/clearcase/info) – VonC Aug 17 '12 at 13:45

3 Answers3

2

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Good idea. Anyway, it turns out as another path issue. I ran a huge .bat file to setup the environment before run the BuildForge scripts. The path somehow was not right. Once I copied the path from the current CMD window. It resolved. Thanks again! – Alex Aug 17 '12 at 14:29
0

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.

Vidul
  • 10,128
  • 2
  • 18
  • 20
0

To get the current working directory, you should be using Cwd's getdcwd function:

use Cwd;

my $current_dir = getdcwd 'M:';
Alan Haggai Alavi
  • 72,802
  • 19
  • 102
  • 127