#!/usr/bin/perl
my($host, $username, $password);
$host="서버IP";
$username="root";
#$password="";
use strict;
use Net::SSH::Perl;
my @KEYFILE = ("/root/.ssh/id_rsa");
my $ssh = Net::SSH::Perl->new($host, debug=>0, identity_files=>\@KEYFILE);
$ssh->login($username);
my($local_dir, $local_filename, $remote_dir, $remote_filename);
#$remote_dir = "/home/ruis";
#$remote_filename = "passwd";
$local_dir = "/root/perl";
$local_filename = "_httpd";
open FILE, "> $local_dir/$local_filename";
open FILE1, "> $local_dir/_uptime";
#print FILE ($ssh->cmd("cat $remote_dir/$remote_filename"))[0];
#print FILE ($ssh->cmd("cat /etc/sysconfig/network-scripts/ifcfg-eth0"))[0];
print FILE ($ssh->cmd("pstree"))[0];
print FILE1 ($ssh->cmd("uptime"))[0];
#$ssh->cmd("");
#### Perl ssh 원격접속 Test 파일
#### 해당 파일을 기본골격으로 여러가지 원격 명령 Perl 파일이 생성가능
### Last version 20141021 ###
'IT Study > script' 카테고리의 다른 글
nfs를 이용한 간단한 백업 스크립트 (0) | 2016.02.19 |
---|---|
tomcat 프로세스 재구동 스크립트 (0) | 2016.02.19 |
check storage (0) | 2016.02.19 |
서버 스크립트 자동 배포 (0) | 2014.10.21 |
ssh원격 접속 명령 (0) | 2014.10.21 |