Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Unix-системы [игнор отключен] [закрыт для гостей] / ssh in tput / 1 сообщений из 1, страница 1 из 1
02.05.2012, 14:24
    #37779062
mblsha
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
ssh in tput
есть нескольно серверов баз данных с RHEL & Oracle 10/11
я хочю автоматизировать проверку БД - с одно сервера запустить скрип, который по выбору будет выдавать репорты БД, ОС и еще фсякой фигни(.sh scripts)

нашел скрипт с цветами шрифтов, попытался адаптировать... нужна ваша помощь.

Original:
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
 
#!/bin/bash
trap 'get_window_size' WINCH                    # trap when a user has resized the window

_UNDERLINE_ON=`tput smul`                       # turn on underline
_UNDERLINE_OFF=`tput rmul`                      # turn off underline

get_window_size() {
  _WINDOW_X=`tput lines`
  _WINDOW_Y=`tput cols`

  _FULL_SPACES=`echo ""|awk '
  {
    _SPACES = '${_WINDOW_Y}'
    while (_SPACES-- > 0) printf (" ")
  }'`
  _FULL_UNDERLINE=`echo "${_UNDERLINE_ON}${_FULL_SPACES}${_UNDERLINE_OFF}"`

  unset _FULL_SPACES
  show_menu

  return 0
}

set_color() {
  tput clear
  PS3="Enter Selection[1-9]:"
  select _COLOR in "Black" "Blue" "Green" "Cyan" "Red" "Magenta" "Yellow" "White" "Exit"
  do
    case ${REPLY} in
       [1-8])  _X=`expr ${REPLY} - 1`;;
           9)  break;;
           *)  echo "Invalid Color"; continue;;
    esac

    if [[ ${1} = "b" ]]
    then
      tput setb ${_X}
    else
      tput setf ${_X}
    fi
  done
}

show_menu() {
  while [[ -z ${_ANS} ]]
  do
    tput civis
    tput clear

	cat <<- EOF
		Window Size: ${_WINDOW_X} / ${_WINDOW_Y}


		Select => ${_UNDERLINE_ON}     ${_UNDERLINE_OFF}

		${_FULL_UNDERLINE}
		B) Background Text Color
		F) Foreground Text Color

		X) Exit
	EOF

    tput rc
    tput smul
    tput cnorm

    read _ANS
    tput rmul

    case ${_ANS} in
      [Bb])  set_color "b";;
      [Ff])  set_color "f";;
      [Xx])  tput clear; exit;;
         *)
             echo -e "Invalid Selection: ${_ANS}\c"
             sleep 2
             ;;
    esac
    unset _ANS
  done
}

tput sgr0
tput civis
tput clear
tput cup 3 10
tput sc
tput cup 0 0

[[ -n ${_ANS} ]] && unset _ANS
get_window_size

exit 0



Mine:
Код: sql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
#!/bin/bash
# ~/.ssh/config
trap 'get_window_size' WINCH                    # trap when a user has resized the window

_UNDERLINE_ON=`tput smul`                       # turn on underline
_UNDERLINE_OFF=`tput rmul`                      # turn off underline

get_window_size() {
  _WINDOW_X=`tput lines`
  _WINDOW_Y=`tput cols`

  _FULL_SPACES=`echo ""|awk '
  {
    _SPACES = '${_WINDOW_Y}'
    while (_SPACES-- > 0) printf (" ")
  }'`
  _FULL_UNDERLINE=`echo "${_UNDERLINE_ON}${_FULL_SPACES}${_UNDERLINE_OFF}"`

  unset _FULL_SPACES
  show_menu

  return 0
}
set_server() {
  tput clear
  PS3="Enter Selection[1-9]:"
  select _COLOR in "Test" "PDM_DB" "Green" "Cyan" "Red" "Magenta" "Yellow" "White" "Exit"
  do
    case ${REPLY} in
       [1-8])  _X=`expr ${REPLY} - 1`;;
           9)  break;;
           *)  echo "Invalid Server Selection"; continue;;
    esac

    if [[ ${1} = "q" ]]
    then
      tput setb ${_X}
    elif [[ ${1} = "1"]]
        ssh .... /oracle/ORABACKUP/hpcc.sh;;
        else
        continue;;
    fi
  done
}

show_menu() {
  while [[ -z ${_ANS} ]]
  do
    tput civis
    tput clear

        cat <<- EOF
                Window Size: ${_WINDOW_X} / ${_WINDOW_Y}


                Select => ${_UNDERLINE_ON}     ${_UNDERLINE_OFF}

                ${_FULL_UNDERLINE}
                Q) Israel Servers
                W) UK Servers

                X) Exit
        EOF

    tput rc
    tput smul
    tput cnorm

    read _ANS
    tput rmul

    case ${_ANS} in
      [Qq])  set_server "Israel Servers";;
      [Ww])  set_server "UK Servers";;
      [Xx])  tput clear; exit;;
         *)
             echo -e "Invalid Selection: ${_ANS}\c"
             sleep 2
             ;;
    esac
    unset _ANS
  done
}

tput sgr0
tput civis
tput clear
tput cup 3 10
tput sc
tput cup 0 0

[[ -n ${_ANS} ]] && unset _ANS
get_window_size

exit 0



I get errors on ssh command
./test2.sh: line 39: syntax error in conditional expression
./test2.sh: line 40: syntax error near `ssh'
./test2.sh: line 40: ` ssh .... /oracle/ORABACKUP/hpcc.sh;;'
what am I doing wrong?
p.s. tried with spawn ssh .... - same errors,
...
Рейтинг: 0 / 0
Форумы / Unix-системы [игнор отключен] [закрыт для гостей] / ssh in tput / 1 сообщений из 1, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]