- 論壇徽章:
- 1
|
本帖最后由 xiaobaibbb 于 2010-02-02 18:02 編輯
ruby or perl 現(xiàn)成的,非要expect那是沒事找事。- root@debian:~/perl# cat ssh.ruby
- #!/usr/bin/ruby
- require 'net/ssh'
- require 'net/sftp'
- Net::SSH.start('server', 'username', 'password') do |ssh|
- ssh.sftp.connect do |sftp|
- Dir.foreach('.') do |file|
- puts file
- end
- end
- end
復(fù)制代碼
- root@debian:~/perl# cat ssh.perl
- #!/usr/bin/perl
- use Net::SSH::Perl;
- my $ssh = Net::SSH::Perl->new($server);
- $ssh->login($user, $passwd);
- my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
復(fù)制代碼 |
|