linux常用脚本

自动登录expect脚本,login.exp

#!/usr/bin/expect -f
#auto ssh login
set timeout 30
spawn ssh -p 22 -l root 100.100.100.100
expect {
    "yes/no" {send "yes\r"}
    "password:" {send "daydayup\r"}
}
interact

文本替换shell

#!/bin/bash

for i in `find $1 -name "*.html"`
do
  echo $i
  if [ -f $i ];then
    sed -e "s/$2/$3/g" $i >tmp.txt
    if [ $? -eq 0 ];
    then
      echo "$i is replaced!"
      cp -f tmp.txt $i
    else
      echo "$i failed"
    fi
  fi
done
if [ -f tmp.txt ];then
  rm -rf tmp.txt
fi

相关推荐