I've created a number of bash scripts which make it easier for me to run
particular security applications, among them rkhunter. I run the scripts
in gnome-terminal. It's crucial to say at the outset that I've had no
tuition in bash script writing, so I'm sure my scripts won't win any
beauty contest.
In any event, I was happy with my script for running rkhunter, except
for one thing. I had great difficulty reading part of the output of the
script, because that output (from rkhunter itself) was in yellow on a
white background.
I then figured out how to write a script that opened a second window in
gnome-terminal. That second window had a black background, in which my
original script for running rkhunter then ran. Legibility of the yellow
and all other output in the second window is fine.
However, there's a problem. When my script for running rkhunter in the
second window finishes, it automatically exits, leaving me back at the
first window, so that I haven't got a chance to examine the rkhunter
output except as it scrolls by rapidly in the second window.
I therefore want to amend my script for running rkhunter so that it
doesn't end until the user says so.
In a number of places on the Web appears the following script, which I
thought I could borrow:
#!/bin/bash
# Shows how to read a line from stdin
echo "Would you like to exit this script now?"
read answer
if [ "$answer" = y ]
then
echo "Exiting..."
exit 0
fi
I tried that script. There's a tiny problem with it. It exits no matter
what answer the user gives! The only difference between giving a "y"
answer and any other answer is that the word "Exiting" doesn't appear if
one doesn't give a "y" answer.
How should I amend my script to keep the output on the screen until the
user enters some appropriate input?