johndrake
Technical User
- Jul 25, 2002
- 97
Hi All,
I'm trying to delete a symbolic link to a directory and to create a new one to a directory. The symbolic link is not getting deleted, although it says that it is. Each time I run this I should get the following:
link is /home/jpape/wlcbs_current_build
/home/jpape/wlcbs_current_build points at '/home/jpape/wlcbs_4'
Essentially this is what I am hoping to create each time run the code:
lrwxrwxrwx 1 jpape jpape 19 Jan 29 15:09 wlcbs_current_build -> /home/jpape/wlcbs_4
When I run the program second time, this is what I am getting:
link is /home/jpape/wlcbs_current_build
deleting /home/jpape/wlcbs_current_build
/home/jpape/wlcbs_current_build points at '/home/jpape/wlcbs_current_build'
Here is my code:
sub set_links
{
#print "$path/wlcbs_current_build\n";
$link = "$path/wlcbs_current_build";
print "link is $link\n";
# delete link
# symbolic link information
if (-e $link)
{
print "deleting $link\n";
unlink($link);
}
# create symbolic link
symlink("$path/$max_wlcbs","$path/wlcbs_current_build") ||
die "cannot symlink $path/$min_wlcbs $path/$max_wlcbs";
# symbolic link information
if (defined($x = readlink("$path/wlcbs_current_build")))
{
print "$path/wlcbs_current_build points at '$x'\n";
}
}
Thanks!
-Joe
I'm trying to delete a symbolic link to a directory and to create a new one to a directory. The symbolic link is not getting deleted, although it says that it is. Each time I run this I should get the following:
link is /home/jpape/wlcbs_current_build
/home/jpape/wlcbs_current_build points at '/home/jpape/wlcbs_4'
Essentially this is what I am hoping to create each time run the code:
lrwxrwxrwx 1 jpape jpape 19 Jan 29 15:09 wlcbs_current_build -> /home/jpape/wlcbs_4
When I run the program second time, this is what I am getting:
link is /home/jpape/wlcbs_current_build
deleting /home/jpape/wlcbs_current_build
/home/jpape/wlcbs_current_build points at '/home/jpape/wlcbs_current_build'
Here is my code:
sub set_links
{
#print "$path/wlcbs_current_build\n";
$link = "$path/wlcbs_current_build";
print "link is $link\n";
# delete link
# symbolic link information
if (-e $link)
{
print "deleting $link\n";
unlink($link);
}
# create symbolic link
symlink("$path/$max_wlcbs","$path/wlcbs_current_build") ||
die "cannot symlink $path/$min_wlcbs $path/$max_wlcbs";
# symbolic link information
if (defined($x = readlink("$path/wlcbs_current_build")))
{
print "$path/wlcbs_current_build points at '$x'\n";
}
}
Thanks!
-Joe