0

I have a problem to write script for checking server. Anyway my script sticks on "shell" line of code.

When I execute command "shell" inside of script, it won't go further to other command. so basically look like this:

#!/bin/sh
#exec > output.txt

echo -en '\n'
echo -en '\n'
echo "-------------------------- Daily Check Script ------------------------------"
echo "                                                                      MYteam"
echo -en '\n'
echo "CHECK MASTER/SLAVE node----------------------------------------------------"
echo -en '\n'

var="$(hbmode status )"

if [[ $var =~ "M_WITH_S / S_WITH_M" ]]; then
    echo "You are on MASTER node"
else
    echo "You are on SLAVE node"
fi

current_date=$(date)

echo -en '\n'
echo "Today is ---------------------------------------------------------------"
#echo -en '\n'
echo "Today is $current_date"
echo -en '\n'
echo "Checking SERVER VIP active-----------------------------------------"

shell 

After "shell" command, I get this:

Local controller version is 3.0.0
 Usage : Type <tab> or help for commands and completion.

server1.it.sunburning.gr>

I need to type command: vdip route show but script won't execute this command.

How can I inside of script execute shell and vdip route show command, and exit from shell afterwards to execute other commands like , df -h, free -m etc....

I want to use this script in Cron.

6
  • 2
    what does shell command do ? You need interactive shell? Commented Jul 26, 2022 at 13:29
  • expect (tcl)(wikipedia) is designed for this sort of thing. or you may be able to just redirect input to shell from a file or heredoc Commented Jul 26, 2022 at 13:41
  • Hi there, well shell command do nothing, just set environment for command "vdip route show" .. so lets say YES it need to be interactive and i need after "vdip route show" command to exit shell to continue with script commands like (df -h, free -m.. etc) Thank you. Commented Jul 26, 2022 at 13:42
  • 1
    Please edit your question to provide requested information, don't use comments for this purpose. How do you exit from the shell command? Do you have to type a command like exit or quit? Do you press CTRL+D? Did you try echo vdip route show | shell? Commented Jul 26, 2022 at 13:49
  • Tnx Bodo "echo vdip route show | shell" This works <3 Commented Jul 26, 2022 at 13:51

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.