4 use vars qw(@ISA @EXPORT_OK $ssh $scp);
10 @EXPORT_OK = qw(ssh scp issh iscp sshopen2 sshopen3);
17 FS::SSH - Subroutines to call ssh and scp
21 use FS::SSH qw(ssh scp issh iscp sshopen2 sshopen3);
25 issh($host, $command);
27 scp($source, $destination);
29 iscp($source, $destination);
31 sshopen2($host, $reader, $writer, $command);
33 sshopen3($host, $reader, $writer, $error, $command);
37 Simple wrappers around ssh and scp commands.
43 =item ssh HOST, COMMAND
45 Calls ssh in batch mode.
50 my($host,$command)=@_;
51 my(@cmd)=($ssh, "-o", "BatchMode yes", $host, $command);
52 # print join(' ',@cmd),"\n";
57 =item issh HOST, COMMAND
59 Prints the ssh command to be executed, waits for the user to confirm, and
60 (optionally) executes the command.
65 my($host,$command)=@_;
66 my(@cmd)=($ssh, $host, $command);
67 print join(' ',@cmd),"\n";
69 ###print join(' ',@cmd),"\n";
74 =item scp SOURCE, DESTINATION
76 Calls scp in batch mode.
82 my(@cmd)=($scp,"-Bprq",$src,$dest);
83 # print join(' ',@cmd),"\n";
88 =item iscp SOURCE, DESTINATION
90 Prints the scp command to be executed, waits for the user to confirm, and
91 (optionally) executes the command.
97 my(@cmd)=($scp,"-pr",$src,$dest);
98 print join(' ',@cmd),"\n";
100 ###print join(' ',@cmd),"\n";
105 =item sshopen2 HOST, READER, WRITER, COMMAND
107 Connects the supplied filehandles to the ssh process (in batch mode).
112 my($host,$reader,$writer,$command)=@_;
113 open2($reader,$writer,$ssh,'-o','Batchmode yes',$host,$command);
116 =item sshopen3 HOST, WRITER, READER, ERROR, COMMAND
118 Connects the supplied filehandles to the ssh process (in batch mode).
123 my($host,$writer,$reader,$error,$command)=@_;
124 open3($writer,$reader,$error,$ssh,'-o','Batchmode yes',$host,$command);
128 print "Proceed [y/N]:";
129 my($x)=scalar(<STDIN>);
137 scp stuff should transparantly use rsync-over-ssh instead.
141 L<ssh>, L<scp>, L<IPC::Open2>, L<IPC::Open3>