1SCP(3)                User Contributed Perl Documentation               SCP(3)
2
3
4

NAME

6       Net::SCP - Perl extension for secure copy protocol
7

SYNOPSIS

9         #procedural interface
10         use Net::SCP qw(scp iscp);
11         scp($source, $destination);
12         iscp($source, $destination); #shows command, asks for confirmation, and
13                                      #allows user to type a password on tty
14
15         #OO interface
16         $scp = Net::SCP->new( "hostname", "username" );
17         #with named params
18         $scp = Net::SCP->new( { "host"=>$hostname, "user"=>$username } );
19         $scp->get("filename") or die $scp->{errstr};
20         $scp->put("filename") or die $scp->{errstr};
21         #tmtowtdi
22         $scp = new Net::SCP;
23         $scp->scp($source, $destination);
24
25         #Net::FTP-style
26         $scp = Net::SCP->new("hostname");
27         $scp->login("user");
28         $scp->cwd("/dir");
29         $scp->size("file");
30         $scp->get("file");
31         $scp->quit;
32

DESCRIPTION

34       Simple wrappers around ssh and scp commands.
35

SUBROUTINES

37       scp SOURCE, DESTINATION
38           Can be called either as a subroutine or a method; however, the sub‐
39           routine interface is depriciated.
40
41           Calls scp in batch mode, with the -B -p -q and -r options.  Returns
42           false upon error, with a text error message accessable in
43           $scp->{errstr}.
44
45           Returns false and sets the errstr attribute if there is an error.
46
47       iscp SOURCE, DESTINATION
48           Can be called either as a subroutine or a method; however, the sub‐
49           routine interface is depriciated.
50
51           Prints the scp command to be execute, waits for the user to con‐
52           firm, and (optionally) executes scp, with the -p and -r flags.
53
54           Returns false and sets the errstr attribute if there is an error.
55

METHODS

57       new HOSTNAME [ USER ] ⎪ HASHREF
58           This is the constructor for a new Net::SCP object.  You must spec‐
59           ify a hostname, and may optionally provide a user.  Alternatively,
60           you may pass a hashref of named params, with the following keys:
61
62               host - hostname
63               user - username
64               interactive - bool
65               cwd - current working directory on remote server
66
67       login [USER]
68           Compatibility method.  Optionally sets the user.
69
70       cwd CWD
71           Sets the cwd (used for a subsequent get or put request without a
72           full pathname).
73
74       get REMOTE_FILE [, LOCAL_FILE]
75           Uses scp to transfer REMOTE_FILE from the remote host.  If a local
76           filename is omitted, uses the basename of the remote file.
77
78       mkdir DIRECTORY
79           Makes a directory on the remote server.  Returns false and sets the
80           errstr attribute on errors.
81
82           (Implementation note: An ssh connection is established to the
83           remote machine and '/bin/mkdir -p' is used to create the direc‐
84           tory.)
85
86       size FILE
87           Returns the size in bytes for the given file as stored on the
88           remote server.  Returns 0 on error, and sets the errstr attribute.
89           In the case of an actual zero-length file on the remote server, the
90           special value '0e0' is returned, which evaluates to zero when used
91           as a number, but is true.
92
93           (Implementation note: An ssh connection is established to the
94           remote machine and wc is used to determine the file size.)
95
96       put LOCAL_FILE [, REMOTE_FILE]
97           Uses scp to trasnfer LOCAL_FILE to the remote host.  If a remote
98           filename is omitted, uses the basename of the local file.
99
100       binary
101           Compatibility method: does nothing; returns true.
102

FREQUENTLY ASKED QUESTIONS

104       Q: How do you supply a password to connect with ssh within a perl
105       script using the Net::SSH module?
106
107       A: You don't.  Use RSA or DSA keys.  See the ssh-keygen(1) manpage.
108
109       Q: My script is "leaking" ssh processes.
110
111       A: See "How do I avoid zombies on a Unix system" in perlfaq8,
112       IPC::Open2, IPC::Open3 and "waitpid" in perlfunc.
113

AUTHORS

115       Ivan Kohler <ivan-netscp_pod@420.am>
116
117       Major updates Anthony Deaver <bishop@projectmagnus.org>
118
119       Thanks to Jon Gunnip <jon@soundbite.com> for fixing a bug with size().
120
121       Patch for the mkdir method by Anthony Awtrey <tony@awtrey.com>
122
124       Copyright (c) 2000 Ivan Kohler.  Copyright (c) 2000 Silicon Interactive
125       Software Design.  Copyright (c) 2000 Freeside Internet Services, LLC
126       All rights reserved.  This program is free software; you can redis‐
127       tribute it and/or modify it under the same terms as Perl itself.
128

BUGS

130       Still has no-OO cruft.
131
132       In order to work around some problems with commercial SSH2, if the
133       source file is on the local system, and is not a directory, the -r flag
134       is omitted.
135
136       It's probably better just to use SSH1 or OpenSSH
137       <http://www.openssh.com/>
138
139       The Net::FTP-style OO stuff is kinda lame.  And incomplete.
140

SEE ALSO

142       scp(1), ssh(1)
143
144
145
146perl v5.8.8                       2004-03-03                            SCP(3)
Impressum