刘伟 发表于 2018-8-23 10:49:12

shell,时钟

  #######时钟
  #!/bin/bash
  MIN=1
  HOUR=1
  for ((SEC=5;SEC>=0;SEC--))
  do
  echo -ne "${HOUR}:${MIN}:${SEC}s 后结束"
  sleep 1
  echo -ne "\r\r"
  while [ "$SEC" -le "0" -a "$MIN" -ge "0" ]
  do
  echo -ne "${HOUR}:${MIN}:${SEC}s 后结束"
  echo -ne "\r\r"
  ((MIN--))
  SEC=60
  while [ "$MIN" -lt "0" -a "$HOUR" -gt "0" ]
  do
  echo -ne "${HOUR}:${MIN}:${SEC}s 后结束"
  echo -ne "\r\r"
  ((HOUR--))
  MIN=59
  done
  done
  while [ "$SEC" = "0" -a "$MIN" = "0" -a "$HOUR" = "0" ]
  do
  echo"时间已到!!........."
  break
  done
  done
  # sh clock1.sh
  1:0:48s 后结束^C
  2.测试主机是否开启,并建立用户
  # vim ssh.exp
  #!/usr/bin/expect
  set timeout 3
  set IP
  set PASS
  set COMM
  spawn ssh root@$IP $COMM
  expect {
  "yes/no"
  {send "yes/r";exp_continue}
  "password:"
  {send "$PASS\r"}
  }
  expect eof
  spawn /root/Desktop/shell/ask.sh
  expect "name:"
  send "liu\r"
  expect "old"
  send "17\r"
  expect "class"
  send "8\r"
  expect eof
  #!/bin/bash
  for NUM in {15..20}
  do
  ping -c1 -w1 172.25.254.$NUM &> /dev/null && (
  /mnt/ssh.exp 172.25.254.$NUM redhat hostname | grep -E "The|ECDSA|connecting|Warning|password|spawn" -v|sed "s/Permission\ denied\,\ please\ try\ again\./172.25.254.$NUM password is error/g"
  )
  done
  ???

页: [1]
查看完整版本: shell,时钟