Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: -e file test won't follow symlinks?

by Khen1950fx (Canon)
on Jun 12, 2011 at 01:08 UTC ( #909277=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://909277]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2018-01-19 06:18 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (215 votes). Check out past polls.