The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

IPC::PerlSSH::Library::FS - a library of filesystem functions for IPC::PerlSSH

SYNOPSIS

use IPC::PerlSSH;

my $ips = IPC::PerlSSH->new( Host => "over.there" );

$ips->use_library( "FS", qw( mkdir chmod writefile ) );

$ips->call( "mkdir", "/tmp/testing" );
$ips->call( "chmod", 0600, "/tmp/testing" );

$ips->call( "writefile", "/tmp/testing/secret", <<EOF );
Some secret contents of my file here
EOF

DESCRIPTION

This module provides a library of functions for interating with the remote filesystem. It provides wrappers for most of the perl filesystem functions, and some useful new functions that are more convenient to call remotely.

Because of the large number of functions defined by this library, it is recommended to only load the ones being used by the program, to avoid sending unnecessary data when setting up SSH connections across slow links.

FUNCTIONS

Simple Functions

The following perl functions have trivial wrappers that take arguments and return values in the same way as perl's. They throw exceptions via the IPC::PerlSSH call when they fail, rather than returning undef, because otherwise $! would be difficult to obtain.

chown chmod lstat mkdir readlink rename rmdir stat symlink unlink utime

The following functions are imported from File::Path with the following API adjustments:

mkpath( $path, %opts ) # %opts supports mode, user, group
rmtree( $path, %opts ) # %opts supports safe, keep_root

Variations on stat()

The following functions each returns just one element from the stat() list for efficiency when only one is required.

stat_dev stat_ino stat_mode stat_nlink stat_uid stat_gid stat_rdev
stat_size stat_atime stat_mtime stat_ctime stat_blksize stat_blocks

The following stored functions wrap the perl -X file tests (documented here in the same order as in perldoc perlfunc)

stat_readable stat_writable stat_executable stat_owned

stat_real_readable stat_real_writable stat_real_executable
stat_real_owned

stat_exists stat_isempty stat_size

stat_isfile stat_isdir stat_islink stat_ispipe stat_issocket
stat_isblock stat_ischar

stat_issetuid stat_issetgid stat_issticky

stat_istext stat_isbinary

stat_mtime_days stat_atime_days stat_ctime_days

Variation Functions

The following functions are defined as variations on the perl function of the same name

my @ents = $ips->call( "readdir", $dirpath, $hidden );

Return a list of the directory entries. Hidden files are skipped if $hidden is true. . and .. are always skipped.

$ips->call( "remove", $path );

Calls rmdir if $path is a directory, or unlink if not

New Functions

The following functions are newly defined to wrap common perl idoms

my $content = $ips->call( "readfile", $filepath );
$ips->call( "writefile", $filepath, $newcontent );

To open a remote filehandle and interact with it over a sequence of multiple calls, see also IPC::PerlSSH::Library::IO.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>