melrom
January 28th, 2010, 11:47 PM
Hi everyone-
I've been experiencing some weird problems with a perl script that I moved from one server to another. perl version is perl, v5.8.8, running on RHEL.
The basic idea is the following. I check if a dir exists via the if(-d /path/of/dir) and then I try to cd into it (it's should be a link). Anyway, for example's sake:
my $temp = `cd /path/to/dir 2>&1`;
if($temp eq ''){
print "Empty\n";
}else{
print "!empty: $temp\n";
}
Even when /path/to/dir completely does NOT exist, I still get that $temp is an empty string. I was anticipating getting the 'cd: directory does not exist'. If I take away the 2>&1, I still get no output to the variable. I tried wrapping this in a system call:
my $temp = system("cd /path/to/dir");
except that gives me -1 when the directory DOES exist.
Any ideas on what I'm doing wrong?
I've been experiencing some weird problems with a perl script that I moved from one server to another. perl version is perl, v5.8.8, running on RHEL.
The basic idea is the following. I check if a dir exists via the if(-d /path/of/dir) and then I try to cd into it (it's should be a link). Anyway, for example's sake:
my $temp = `cd /path/to/dir 2>&1`;
if($temp eq ''){
print "Empty\n";
}else{
print "!empty: $temp\n";
}
Even when /path/to/dir completely does NOT exist, I still get that $temp is an empty string. I was anticipating getting the 'cd: directory does not exist'. If I take away the 2>&1, I still get no output to the variable. I tried wrapping this in a system call:
my $temp = system("cd /path/to/dir");
except that gives me -1 when the directory DOES exist.
Any ideas on what I'm doing wrong?