Results 1 to 6 of 6
was wondering if anyone knew how to run a bash script on the web? What my script needs to do is when the menu is ran it needs to wait ...
- 12-13-2007 #1Just Joined!
- Join Date
- Dec 2007
- Posts
- 3
Web Bash Menu
was wondering if anyone knew how to run a bash script on the web? What my script needs to do is when the menu is ran it needs to wait for a user to imput a command. I can get the script to run but it just goes into a loop and wont let the user input anything.
Any help would be greatly appreciated.
This is my main bash script:
You can see what its doing by running the script name with is_oos_menu
example dma_menu.sh is_oos_menu
#! /bin/sh
#set -x
cd /scripts/tcy/f5;
DATE=`date +"%Y/%m/%d %H:%M"`
scripts="/usr/local/bin/scripts/gt/f5/v2"
USER=`who am i | cut -c1-8`
stty erase ^H
#Setup Name Resolution
LOG="/scripts/gt/f5/v2/gt_names.log"
DMA0=`cat $LOG | grep -i DMA0= | awk -F '=' {'print $2'}`
DMA1=`cat $LOG | grep -i DMA1= | awk -F '=' {'print $2'}`
DMCERT0=`cat $LOG | grep -i DMCERT0= | awk -F '=' {'print $2'}`
#Setting up GTLB01
if [[ `ssh -l mrc 10.21.2.4 b fo | grep -ic "active"` -eq 1 ]]
then
LB01="10.21.2.4"
elif [[ `ssh -l mrc 10.21.1.5 b fo | grep -ic "active"` -eq 1 ]]
then
LB01="10.21.2.5"
fi
cd /scripts/gt/f5
icontrol="/usr/bin/perl /scripts/gt/f5/bigip.pl blah@$LB01"
case $1 in
"" )
echo "
DMA QA IS/OOS Script
You must run this script with one of the following options:
menu - Main Menu
is_oos_menu - IS/OOS Menu
status - IS/OOS Status
"
echo"";;
#DM QA Menu
"menu" )
while true
do
clear
echo " Select an option from the list below:
1) DMA QA IS/OOS
S) Status of DMA QA Servers
Q) Quit
Please type a letter (from the above choices)
then press the RETURN key"
read answer
clear
case "$answer" in
1) $scripts/dma_qa_master.sh is_oos_menu;;
[Ss]*) $scripts/dma_qa_master.sh status | more;;
[Qq]*) echo "Quitting the menu program" ; exit 0 ;;
*) echo "Please choose an option which is displayed on the menu" ;;
esac
echo ""
echo "PRESS RETURN FOR THE MENU"
read dummy
done
exit 0;;
"is_oos_menu" )
clear
#trap "echo 'Control-C cannot be used' ; sleep 1 ; clear ; continue " 2
while true
do
clear
echo "
DMA QA IS/OOS Menu
***DMA-TUL-0***
1) DMA-TUL-0 IS
2) DMA-TUL-0 OOS
***DMA-TUL-1***
3) DMA-TUL-1 IS
4) DMA-TUL-1 OOS
***DMCERT-TUL-0
5) DMCERT-TUL-0 IS
6) DMCERT-TUL-0 OOS
Select a server action from below:
S) Check status of DMA QA servers on the BigIP
Q) QUIT (Leave this menu program)
Please type a number (from the above choices)
then press the RETURN key:"
read answer
clear
case "$answer" in
1) $icontrol enablenodes dm_qa_reg $DMA0:8001
clear
echo "Status of DMA-TUL-0..."
ssh -l mrc $LB01 b pool dm_qa_reg |grep $DMA0 |cut -c4-80
echo ""
echo `date +"%Y/%m/%d %H:%M"`, DMA-TUL-0, Port 8001/dm_qa_reg IS, "Placed IS by:" $USER >>/var/log/monitoring/gt/is_oos/is-oos.history.log;;
2) $icontrol disablenodes dm_qa_reg $DMA0:8001
clear
echo "Status of DMA-TUL-0..."
ssh -l mrc $LB01 b pool dm_qa_reg |grep $DMA0 |cut -c4-80
echo ""
echo `date +"%Y/%m/%d %H:%M"`, DMA-TUL-0, Port 8001/dm_qa_reg OOS, "Placed OOS by:" $USER >>/var/log/monitoring/gt/is_oos/is-oos.history.log;;
3) $icontrol enablenodes dm_qa_reg $DMA1:8001
clear
echo "Status of DMA-TUL-1..."
ssh -l mrc $LB01 b pool dm_qa_reg |grep $DMA1 |cut -c4-80
echo ""
echo `date +"%Y/%m/%d %H:%M"`, DMA-TUL-1, Port 8001/dm_qa_reg IS, "Placed OOS by:" $USER >>/var/log/monitoring/gt/is_oos/is-oos.history.log;;
4)$icontrol disablenodes dm_qa_reg $DMA1:8001
clear
echo "Status of DMA-TUL-1..."
ssh -l mrc $LB01 b pool dm_qa_reg |grep $DMA1 |cut -c4-80
echo ""
echo `date +"%Y/%m/%d %H:%M"`, DMA-TUL-1, Port 8001/dm_qa_reg OOS, "Placed OOS by:" $USER >>/var/log/monitoring/gt/is_oos/is-oos.history.log;;
5) $icontrol enablenodes dm_qa_reg $DMCERT:8001
clear
echo "Status of DMCERT-TUL-0..."
ssh -l mrc $LB01 b pool dm_qa_reg | grep $DMCERT0 | cut -c4-80
echo""
echo `date +"%Y/%m/%d %H:%M"`, DMCERT-TUL-0, Port 8001/dm_qa_reg IS, "Placed OOS by:" $USER >>/var/log/monitoring/gt/is_oos/is-oos.history.log;;
6) $icontrol disablenodes dm_qa_reg $DMCERT0:8001
clear
echo "Status of DMCERT-TUL-0..."
ssh -l mrc $LB01 b pool dm_qa_reg | grep $DMCERT0 | cut -c4-80
echo""
echo `date +"%Y/%m/%d %H:%M"`, DMCERT-TUL-0, Port 8001/dm_qa_reg OOS, "Placed OOS by:" $USER >>/var/log/monitoring/gt/is_oos/is-oos.history.log;;
[Ss]*) $scripts/dma_qa_master.sh status | more;;
[Qq]*) echo "Quitting the menu program" ; exit 0 ;;
*) echo "Please choose an option which is displayed on the menu" ;;
esac
echo ""
echo "PRESS RETURN FOR THE MENU"
read dummy
done;;
#DMA Status
"status" )
echo "Status of DMA-TUL-0..."
ssh -l mrc $LB01 b pool dm_qa_reg |grep $DMA0 |cut -c4-80
echo ""
echo "Status of DMA-TUL-1..."
ssh -l mrc $LB01 b pool dm_qa_reg |grep $DMA1 |cut -c4-80
echo ""
echo "Status of DMCERT-TUL-0..."
ssh -l mrc $LB01 b pool dm_qa_reg |grep $DMCERT0 |cut -c4-80
echo ""
esac
Thanks for any help you can give.
Greg
- 12-13-2007 #2
I'm confused. Explain, please, how the web is related to this.
--
Bill
Old age and treachery will overcome youth and skill.
- 12-16-2007 #3Just Joined!
- Join Date
- Dec 2007
- Posts
- 3
I just want to be able to make this accessable from the web and I have no idea how to do that or even start. Any help will be appreciated.
Thanks
Greg
btw I stay confused
- 12-16-2007 #4
Wow.
As I see it, you wish to make it possible for a person with a web browser to run this script as though he had a shell prompt.
The simplest way, as far as I can see, is to write a CGI program (a CGI script in Perl is one way to go) that throws up web pages asking for the responses you'd want from the user, and uses cookies to keep track of the state of the conversation.
This is not an easy thing to explain in a forum like this. Particularly, the security implications alone are enough to give one pause.
But if you really, really want to do this, and are not afraid of the risk of shooting yourself in the foot big time, google for this:
You should find everything you need there, though it's not the sort of project you'll finish in a week or two. If you design it well, it will take longer than that.Code:CGI tutorial
Hope this helps.--
Bill
Old age and treachery will overcome youth and skill.
- 12-16-2007 #5Just Joined!
- Join Date
- Dec 2007
- Posts
- 3
Thanks for the help. I would in the end make it all go through a portal page that logs and has privelages. Plus I just really want to learn that. I sort of know whats going on with scripting in bash.
Again thanks for your help.
Greg
- 12-16-2007 #6
I don't really know what you mean by "make it go through a portal page". If you have complete knowledge of what that means for you, then the answer of how to incorporate a bash script will most likely be in there somewhere. If it's not, then the answer lies in CGI programming.
And be sure that "making it go through a portal page that logs and has privileges" solves the security problems. By "security problems", I don't mean "having enough privileges"; I mean "not having too many privileges, or using them in a way that invites damage from evildoers". It won't solve these security problems, unless you do enough research to satisfy yourself that it does.--
Bill
Old age and treachery will overcome youth and skill.


Reply With Quote