Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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;


Comment on Re: -e file test won't follow symlinks?
Select or Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://909277]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2014-04-20 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls