Я новичок в скриптах bash.
Я запускаю скрипт bash с сервера server1, который запустит ssh на удаленный сервер и запустит скрипт на нем.
Этот удаленный скрипт должен иметь некоторые пользовательские входы, но когда я запускаю скрипт, он игнорирует пользовательские входы.
Я могу подключиться к удаленному серверу и выполнить команды (я проверил простые команды, такие как 'hostname' и 'cd', но пользовательская часть ввода не работает.
Ниже приведены подробности, любая помощь приветствуется.
Скрипт на сервере1:
#!/bin/bash
ssh -q -oStrictHostKeyChecking=no “remote_server” sudo su - root << EOF
bash <(curl -sk http://jumpserver/pub/bootstrap/menutest.sh)
EOF
Здесь: jumpserver позволяет мне запускать скрипт на всех серверах в моей среде.
Menutest.sh
- это скрипт, который мне нужен для запуска на удаленных серверах
Сценарий на удаленном сервере: menutest.s
#!/bin/bash
echo "you are now logged in to server " ``hostname``
cd /local/log/
echo “ you are now in location” `pwd`
# read the date from user ( this is the date from which user wants to read the file from
echo "Enter the date to read to data ( please provide date only till last 7 days) : "
read n1
echo "the date you entered is $n1"
#extract the file based on the date entered by user
file=$(/usr/bin/ls /local/log | grep -i log | grep -i $n1)
echo " the log file from" $n1 " is " $file
#read the time for which the user needs the information from in that log file
echo "Enter the time to read to data ( please provide time in hh:mm format with 5 mins interval ( eg 05:35, 13:45 etc) : "
read n2
echo " the time you entered is $n2"
cpu_mem_data=$(cat $file | grep $n2 -A 30)
echo "$cpu_mem_data"
Вот вывод прогона скрипта с сервера1:
enter the server name
cvmlnx0091
server chosen is cvmlnx0091
Enter the date to read to data ( please provide date only till last 7 days) :
24
the date you entered is 24
Enter the time to read to data ( please provide time in hh:mm format with 5 mins interval ( eg 05:35, 13:45 etc) :
14:15
the time you entered is 14:15
you are now logged in to server CVMLNX0091
/local/log
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
the log file from is
reading data from it......
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
Что я здесь не так делаю?