diff options
author | ivan <ivan> | 2002-03-16 02:00:10 +0000 |
---|---|---|
committer | ivan <ivan> | 2002-03-16 02:00:10 +0000 |
commit | 39a05dcd4f7edf5eb89c2870eff5ae2df8bb381b (patch) | |
tree | 03e518fb7a3234041566ca9f3d36cf8ad126fdc4 | |
parent | 00c241c204d6d94bb1a0352b73a217436bde845e (diff) |
mkdir method from Anthony Awtrey <tony@awtrey.com>
-rw-r--r-- | Changes | 3 | ||||
-rw-r--r-- | SCP.pm | 39 |
2 files changed, 39 insertions, 3 deletions
@@ -1,5 +1,8 @@ Revision history for Perl extension Net::SCP. +0.06 unreleased + - mkdir method added by Anthony Awtrey <tony@awtrey.com> + 0.05 Wed Oct 24 03:49:06 2001 - documentation update @@ -12,7 +12,7 @@ use IPC::Open3; @ISA = qw(Exporter); @EXPORT_OK = qw( scp iscp ); -$VERSION = '0.05'; +$VERSION = '0.06'; $scp = "scp"; @@ -206,6 +206,36 @@ sub get { scp($source,$local); } +=item mkdir DIRECTORY + +Makes a directory on the remote server. Returns false and sets the B<errstr> +attribute on errors. + +(Implementation note: An ssh connection is established to the remote machine +and '/bin/mkdir B<-p>' is used to create the directory.) + +=cut + +sub mkdir { + my($self, $directory) = @_; + $directory = $self->{'cwd'}. "/$directory" + if $self->{'cwd'} && $directory !~ /^\//; + my $host = $self->{'host'}; + $host = $self->{'user'}. '@'. $host if $self->{'user'}; + my($reader, $writer, $error ) = + ( new IO::Handle, new IO::Handle, new IO::Handle ); + $writer->autoflush(1); + my $pid = sshopen3( $host, $writer, $reader, $error, + '/bin/mkdir', '-p ', shell_quote($directory) ); + waitpid $pid, 0; + if ( $? >> 8 ) { + chomp(my $errstr = <$error>); + $self->{errstr} = $errstr || "mkdir exited with status ". $?>>8; + return 0; + } + 1; +} + =item size FILE Returns the size in bytes for the given file as stored on the remote server. @@ -225,7 +255,7 @@ sub size { $host = $self->{'user'}. '@'. $host if $self->{'user'}; my($reader, $writer, $error ) = ( new IO::Handle, new IO::Handle, new IO::Handle ); - $writer->autoflush(1);# $error->autoflush(1); + $writer->autoflush(1); #sshopen2($host, $reader, $writer, 'wc', '-c ', shell_quote($file) ); my $pid = sshopen3($host, $writer, $reader, $error, 'wc', '-c ', shell_quote($file) ); @@ -287,10 +317,13 @@ L<IPC::Open3> and L<perlfunc/waitpid>. =head1 AUTHORS Ivan Kohler <ivan-netscp_pod@420.am> -Anthony Deaver <bishop@projectmagnus.org> + +Major updates Anthony Deaver <bishop@projectmagnus.org> Thanks to Jon Gunnip <jon@soundbite.com> for fixing a bug with size(). +Patch for the mkdir method by Anthony Awtrey <tony@awtrey.com> + =head1 COPYRIGHT Copyright (c) 2000 Ivan Kohler. |