Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> Linux系統教程 >> Linux系統常見問題解答 >> linux expect實現自動登錄腳本

linux expect實現自動登錄腳本

日期:2017/1/20 17:43:01      編輯:Linux系統常見問題解答

 1)安裝expect

  [root@server ~]# yum install -y expect

  2)編寫腳本

  #!/usr/bin/expect -f

  #created by mis_yw 2013-11-30

  #verify virus by system user oa

  #set password [1index $argv 0 ]

  #set timeout 10.

  set file [ lindex $argv 0 ]

  spawn su -c "/opt/kaspersky/kav4fs/bin/kav4fs-control --scan-file $file" root

  expect {

  "*Password:" {send "XXXXXX\r"}

  }

  interact

  #!/bin/sh

  #created by mis_yw 2013-11-30

  #verify virus.

  file=$1

  if [[ ! -e $file ]] ;then

  #echo "$file is not exsit."

  echo no

  exit 0

  fi

  infected=`./verifyvirus $file | grep Infected | grep 0`

  if(($?)) ;then

  echo yes

  else

  echo no

  fi

Copyright © Windows教程網 All Rights Reserved