http://www.perlmonks.org?node_id=909277


in reply to -e file test won't follow symlinks?

I think that symlinks under Plesk have different permissions than Unix permissions. As a work-around, I experimented with Setup::File::Symlink. Instead of checking permissions, I checked for status---either 200 or 304 in this case.

Here I used a dry run. If you want to create a symlink, comment out name and change -dry_run => 1 to 0. It requires 5.10.1+.

#!/usr/bin/perl use Modern::Perl; use Setup::File::Symlink qw(setup_symlink); my $x = '/root/Desktop/tmp'; my $res = setup_symlink( name => "create(dry run)", symlink => "/y", target => "/$x/x", other_args => {-dry_run => 1}, status => 200, exists => 1, ); print "status: 200\n", if $res->[0] == 200; print "status: 304\n", if $res->[0] == 304;

Replies are listed 'Best First'.
Re^2: -e file test won't follow symlinks?
by sedusedan (Monk) on Oct 04, 2012 at 07:00 UTC

    I assume you peeked at the test scripts on the usage of setup_symlink(). My bad for not yet providing a Synopsis, but you don't actually need some of the arguments. You only need:

    my $res = setup_symlink( symlink => "/y", target => "/$x/x", );

    And BTW, I think Setup::File::Symlink is a bit of an overkill in this case.