Interacitve script for Healthcheckup of nodes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Interacitve script for Healthcheckup of nodes
# 1  
Old 05-08-2014
Interacitve script for Healthcheckup of nodes

Hi
This is my first post to this site.Smilie
I want to develop a script with following steps:
1.Script1,2,3 placed at particular path on local server
2.ask for an IP and will directly pick up the correct script matching to the IP (IP could be defined in same script or a new script could be called).
3.By using ssh and scp and execute on the destination server.
4.send the output of script back to local server where all scripts are lying.

Waiting for response...Smilie
Smilie
# 2  
Old 05-08-2014
As far as I'm concerned, unless you demonstrate that you have put forth some effort to solve your own problem, you can continue to wait.

We are here to help, but we are not a free, script-writing service.

Also, if this is homework, there is a dedicated forum with additional requirements. Read the FAQ.

Regards,
Alister
This User Gave Thanks to alister For This Post:
# 3  
Old 05-09-2014
Code:
Code:
#!/bin/bash
 
# clear the screen
tput clear
 
# Move cursor to screen location X,Y (top left is 0,0)
tput cup 3 15
 
# Set a foreground colour using ANSI escape
tput setaf 3
echo "HealthCheckup"
tput sgr0
 
tput cup 5 17
# Set reverse video mode
tput rev
echo "M A I N - M E N U"
tput sgr0
 
tput cup 7 15
echo "1. SDP"
 
tput cup 8 15
echo "2. CCN"
 
tput cup 9 15
echo "3. AIR"
 
tput cup 10 15
echo "4. EMM"
 
# Set bold mode 
tput bold
tput cup 12 15
read -p "Enter your choice [1-4] " choice
 
tput clear
tput sgr0
tput rc
scp /your/script/path/monitor.sh user@node1-IP-address:/tmp/. ;
ssh user@node1-IP-address -t "sudo sh /tmp/monitor.sh > /tmp/node1.txt" ;
scp user@node1-IP-address:/tmp/node1.txt /path/of/your/local/server/. ;
ssh user@node1-IP-address -t "rm -rf /tmp/monitor.sh"



The problem is that i am in search of a command which could corelate the option 1,2,3 with the script 1,2,3 like as soon as i put option1 it should pick correct script and log on to the destination server with the correct script.

Last edited by Scrutinizer; 05-09-2014 at 07:33 AM.. Reason: code tags
# 4  
Old 05-09-2014
So you need to know how to make a choice from a selection?

The case statement may be of use:-
Code:
read -p "Give me a number" choice
case $choice in
   1) echo "You picked option 1"
      echo This is another statement for option 1"     ;;
   2) echo "You chose the second"                      ;;
   3) echo "The last valid option"                     ;;
   *) echo "Choice $choice is not valid                ;;
esac

Note the end-of-section ;; and the esac to end the statement.


Does that do what you are after?


Robin
# 5  
Old 05-09-2014
I always wonder how people can know 'so much' about tput, but lack to know about select and case statements.
Actualy, its not a selection yet, as the user could write just anything.

Just as an addition to Robin, a select statement which uses a case statement.
Code:
select CHOICE in Back SDP CCN AIR EMM
do	case $CHOICE in
	Back)	break				;;
	SDP)	echo "Selected $CHOICE"		;;
	CCN)	echo "Do stuff for $CHOICE"	;;
	AIR)	echo "Love is in the $CHOICE"	;;
	EMM)	echo "$CHOICE what?"		;;
	*)	echo "$CHOICE invalid."		;;
	esac
done

Hope this helps
Simon

NOTE: This might not present the 'options' that nice as with tput, but it also works well with diffrent terminal-window screensizes.
# 6  
Old 05-09-2014
You need some sort of exit from the select loop. Either a break to step on further in the script if that is applicable, or an exit or return to terminate the script if that is the preference.
Code:
#!/bin/ksh
# What does select do?

echo "Here 1"
select CHOICE in Back SDP CCN AIR EMM QUIT
do      case $CHOICE in
        Back)   break                           ;;
        SDP)    echo "Selected $CHOICE"         ;;
        CCN)    echo "Do stuff for $CHOICE"     ;;
        AIR)    echo "Love is in the $CHOICE"   ;;
        EMM)    echo "$CHOICE what?"            ;;
        QUIT)   echo "$CHOICE chosen"
                return                          ;;
        *)      echo "$CHOICE invalid."         ;;
        esac
done
echo "Here 2"

# 7  
Old 05-09-2014
Hi

What i want to do is that when i select option1, it picks up script1 accordingly from another path and then scp to destination server?

In between selecting the correct script and moving to other server, it will prompt for IP address.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tabulate nodes and subnodes of XML file script

Hello to all, I'd like to tabulate the content of the XML file below, I've been trying with AWK putting the Top node (<KIND>) as RS and so far I'm able to print the first and second field of each record, but I don't know how to continue with the following nodes that have more inner nodes. The... (4 Replies)
Discussion started by: Ophiuchus
4 Replies

2. UNIX for Dummies Questions & Answers

One service, two nodes, HA

Hi all. I have two nodes taken different places. They are connected together on a network. So, i have a service, it works on one of nodes and when the node is unavailable the service should will be launched on other node. Solution: rhel cluster, keepalive, hearbeat...may be Carp but what if... (2 Replies)
Discussion started by: Flomaster
2 Replies

3. High Performance Computing

request more nodes

I am new to cluster commands. But I have tried utilizing: -pe, but I do not know my parallel computing environment. We are running SGE, is there a simpler command to request more nodes? also: qsub -N auto -M name@email.com -m abe auto.sh does not email me at all. Help would be appreciated (0 Replies)
Discussion started by: theawknewbie
0 Replies

4. Shell Programming and Scripting

Run script on HACMP nodes?

Hello All, Anybody knows how can I run script on the AIX HACMP offline node, without logon a offline node? I would like to run a script on the online node and at same time or after the online node on the offline node. Any IDEA? :confused: (3 Replies)
Discussion started by: kalaso
3 Replies

5. Emergency UNIX and Linux Support

Rebooting 3 to 1 Cluster nodes.

hello Gurus, My current set up is 3 to 1 Cluster (SUN Cluster 3.2) running oracle database. Task is to reboot the servers. My query is about the procedure to do the same. My understanding is suspend the databases to avoid switchover. Then execute the command scshutdown to down the cluster... (4 Replies)
Discussion started by: EmbedUX
4 Replies

6. Shell Programming and Scripting

Script for showing only selected nodes

Dear all, I am bit confused lately, I have a xmlfile here: file: book.xml <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> ... (2 Replies)
Discussion started by: penyu
2 Replies

7. Shell Programming and Scripting

Shell script to map XML nodes

Hi folks, I'm a bit of a novice at this but here goes. I want to read in nodes from an XML file, and map the path to each. eg the file is structured <node><nodename>.</nodename> <node><nodename>topnode</nodename> <node><nodename>subnode1</nodename></node> ... (1 Reply)
Discussion started by: mark14
1 Replies

8. UNIX for Advanced & Expert Users

Managing nodes???

Does anyone know something about this? I have no idea what it means and how to do it. but if anyone can give me and explanation and also point me to a website, i'd really appreciate it (5 Replies)
Discussion started by: TRUEST
5 Replies

9. UNIX for Dummies Questions & Answers

nodes

how do you list all the nodes in unix :confused: (3 Replies)
Discussion started by: kamisi
3 Replies

10. UNIX for Dummies Questions & Answers

i-nodes

first off, i am new to unix so please bear with me. i was reading somewhere that if your i-nodes get critical that it can slow your network down. what are i-nodes and when do they become a critical number? this is what mine states: / (/dev/root ): 777058 blocks 569290 i-nodes... (4 Replies)
Discussion started by: djatwork
4 Replies
Login or Register to Ask a Question