chdir($cmd) or die "chdir($cmd) failed: $!";