여러 대의 Liux 서버 파일 을 일괄 삭제 합 니 다.
deletefile
자동 삭제 / recordfile / 아래 디 렉 터 리 에 31 일 이전 파일 의 스 크 립 트 입 니 다.모 서버 에 놓다
- #!/bin/bash
- #to delete files with is 30 day ago
- cd /record_file/
- for i in `ls`
- do
- cd /record_file/$i
- echo `pwd`
- find ./ -mtime +31 > filelist
- sleep 2
- rm -rf `cat filelist`
- sleep 10
- done
expect_run.exp
한 서버 에서 deletefile 파일 을 원 격 서버 로 대량으로 복사 하고 실행 하 는 스 크 립 트 입 니 다.
- #!/usr/tcl/bin/expect
- set timeout 2
- set host [lindex $argv 0]
- set user [lindex $argv 1]
- set password [lindex $argv 2]
- spawn ssh $user@$host
- # Enable this and Disable the "spawn ssh ..." above if you are using ssh-key.
- #spawn ssh -i ssh-key/Identity.ppk -p $port $user@$server
- expect {
- "yes/no)?\ " {send "yes\r";exp_continue}
- "*assword:\ " {send "$password\r"}
- }
- expect "]*"
- send "scp [email protected]:/home/deletefile /home\r"
- expect {
- "yes/no)?\ " {send "yes\r";exp_continue}
- "*assword:\ " {send "123456\r"}
- }
- expect "]*"
- send "cd /home/\r"
- send "nohup ./deletefile &\r"
- expect eof
run.sh expect 호출run. exp 의 주 스 크 립 트
- #!/bin/sh
- cat ip.txt | while read ip user password
- do
- ./expect_run.exp $ip $user $password
- done
ip.txt 설명 하지 않 음, 호스트 목록
- 100.2.3.92 root 123456
- 100.2.3.94 root 123456
- 100.2.3.93 root 123456
- 100.2.3.89 root 123456
- 100.2.3.88 root 123456
- 100.2.3.87 root 123456
- 100.2.3.90 root 123456
- 。。。。
expect 의 설치 및 사용 (tcl 8.5.10 컴 파일 이 성공 하지 못 할 수도 있 음 을 알려 줍 니 다.
이 버 전
A. Tcl 설치 하 다.
홈 페이지:
http://www.tcl.tk
다운로드 주소:
http://www.tcl.tk/software/tcltk/downloadnow84.tml
1. 원본 패키지 다운로드
wget
http://nchc.dl.sourceforge.net/sourceforge/tcl/tcl8.4.11-src.tar.gz
wget
http://nchc.dl.sourceforge.net/sourceforge/tcl/tk8.4.11-src.tar.gz
2. 압축 해제 소스 패키지
tar xfvz tcl8.4.11-src.tar.gz
tar xfvz tk8.4.11-src.tar.gz
3. 설치 설정
cd tcl8.4.11
cd unix
./configure --prefix=/usr/tcl --enable-shared
make
make install
설치 가 끝 난 후 tcl 소스 코드 의 루트 디 렉 터 리 에 들 어가 하위 디 렉 터 리 유 닉 스 아래 tclUnixPort. h 하위 디 렉 터 리 generic 에 복사 합 니 다.
당분간 tcl 소스 코드 를 삭제 하지 마 십시오. expect 의 설치 과정 이 필요 하기 때 문 입 니 다.
B. expect 설치 하 다. (Tcl 라 이브 러 리 필요)
홈 페이지:
http://expect.nist.gov/
1.
원본 패키지 다운로드
Wget
http://nchc.dl.sourceforge.net/project/expect/Expect/5.45/expect5.45.tar.gz
2. 압축 해제 소스 패키지
tar xfvz expect
5.45
.tar.gz
3. 설치 설정
cd expect-5.4
5
./configure --prefix=/usr/expect --with-tcl=/usr/tcl/lib --with-tclinclude=
/ tcl 소스 코드 경로 / generic
make
make install
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
용감한 바로 가기 및 우분투 응용 프로그램안녕하세요 여러분, 이 기사에서는 모든 사이트에서 pwa를 생성하고 실행기 응용 프로그램으로 추가하는 방법을 설명하고 싶습니다. 일부 웹사이트는 PWA로 설치를 허용하지 않지만 유사한 애플리케이션을 원합니다. 1. ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.