/[cvs]/nfo/perl/scripts/sshwrap/sshwrap.pl
ViewVC logotype

Contents of /nfo/perl/scripts/sshwrap/sshwrap.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Mon Jan 20 19:05:05 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +32 -10 lines
File MIME type: text/plain
+ updates

1 #!/usr/bin/perl
2
3 # $Id$
4
5 =pod
6
7 sshwrap - a ssh wrapper
8
9 opens a secure shell connection through a http proxy by using the two fine tools ssh and corkscrew
10
11 sshwrap utilizes some Perl modules from CPAN together with common UNIX programs to provide
12 a kind of API around the known ssh tools. It started as a standalone solution inside a single Perl script,
13 but now uses IPC::Run and Shell.pm to improve modularization and to provide convenient access and functionality.
14
15 Another focus is on Linux-/Windows compatibility and - important for this special case - the possibility
16 to enter a password on the command line. (other ssh wrappers dictate to use keyfiles instead)
17
18 It would be nice to use Net::SSH, Net::SSH::Perl or File::Remote under the hood to dispatch core
19 functions to these modules if needed through some circumstances or explicitly requested.
20 There has been done work going onto this direction, but as i see for now Net::SSH just works with keys
21 and File::Remote is stated to only work on UNIX systems.
22 IPC::Run is compatible since it seems to use Win32::Process under the hood.
23
24 Links:
25 - ssh: http://openssh.org/
26 - corkscrew: http://www.agroman.net/corkscrew/
27 - cygwin: http://www.cygwin.com/
28
29 =cut
30
31 # cvs change history
32 # $Log$
33
34 use strict;
35 use warnings;
36
37 use Data::Dumper;
38 use lib '.';
39 #use Shell::SSH qw( echo hostname );
40 use Shell::SSH;
41
42 # defaults:
43 # - method=ssh, options=proxy_enabled=0
44 # - uses defaults proxy if proxy_enabled=1 and proxy_host is empty
45 my $command = Shell::SSH->new(
46 #method => 'ssh',
47 #method => './tester.sh',
48 target => 'test@webpla.net',
49 #target => 'test@netfrag.org',
50 args => [],
51 #options => { proxy_enabled => 1, proxy_host => 'your-proxy.com:8080' } ,
52 #options => { proxy_enabled => 1 } ,
53 response => \&recieve_callback,
54 );
55
56 # native style - deprecated ;)
57 #$command->run("cat /home/test/test.txt");
58 #sub ps;
59 #print ps -a;
60 #print echo("abc");
61 #print Dumper($output);
62
63 # sym-style
64 #echo("huhu");
65 #print echo("huhu");
66
67 # OO-style
68 # TODO: return values via print "command" (Shell::SSH should block in this case)
69 #print $command->hostname();
70 #print $command->echo("Hello World!"), "\n";
71 #print "sleeping...\n";
72 #sleep 5;
73 $command->hostname();
74 #$command->echo("Hello World!");
75
76 sub recieve_callback {
77 my $output_block = shift;
78 print "output: ", $output_block, "\n";
79 #print $output_block;
80 }
81
82 sleep 1;
83
84 $command->_read_output();
85 #$command->disconnect();
86
87
88
89 print "ready.", "\n";
90 exit;
91
92 my $tgt1 = 5;
93 my $tgt2 = 10;
94
95 my $cnt = 0;
96 while (1) {
97 print ".\n";
98 sleep(1);
99 if ($cnt == $tgt1) { $command->hostname(); }
100 if ($cnt == $tgt2) { $command->_read_output(); }
101 #$command->_read_output();
102 $cnt++;
103 }
104

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed