
How can my shell script test server status?i am in big problem so please help on it. below i write the scripts, i don't know it is correct or not, but i want write the shell script for. In particular machine need to check all process are running or not, and we need result to display in the web page like server name = running, not only single server we have so many servers so, result like in the web page: server1 = running like that so many server we have and one more thing is need show in web page with colors and fonts. please help on it! Since it's apparent that you are at a polytechnic in India (the submission had a ".in" email address suffix) and that you're baffled by what's a fairly rudimentary homework assignment, it would probably be better if I just ignored this question and let you figure it out yourself, but instead I cunningly waited a month or so to get here. That way, it couldn't possibly be helpful to you. :-) Nonetheless, this really is a straightforward project, so straightforward that I will write up a simple script. First off, how do you test to see if a server is running? Use the ping command! For example, let me ping two servers, one I know is running and one I know isn't by virtue of the fact it's an unknown domain: $ ping -o yahoo.com
PING yahoo.com (206.190.60.37): 56 data bytes 64 bytes from 206.190.60.37: icmp_seq=0 ttl=46 time=69.601 ms --- yahoo.com ping statistics --- 1 packets transmitted, 1 packets received, 0% packet loss round-trip min/avg/max/stddev = 69.601/69.601/69.601/0.000 ms $ echo $? 0 $ ping -o xyz.yahoo.com ping: cannot resolve xyz.yahoo.com: Unknown host $ echo $? 68 Really, that should be enough to show you how to proceed, but let's put it in script form: for server in $(cat serverlist)
do ping -o $server > /dev/null 2>&1 if [ $? -eq 0 ] ; then echo "$server = running" else echo "$server = not running" fi done Now that should be enough, shouldn't it? The only slight tweak: if the shell script is going to be called directly within a browser (which requires some modifications to the Apache server configuration) then it needs the following as the very first two lines of output generated by the script: echo "Content-Type: text/html" ; echo ""
Now that should help you quickly gain an "A" in this assignment!
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon
Categorized:
Shell Script Programming
(Article 8418)
Tagged: shell script programming, shell scripting Previous: Does Google AdSense work better on text-based pages? Next: How do I "sculpt pagerank" on my site? Subscribe!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader. what is the wep key Posted by: marco at September 21, 2008 7:38 AMHey! I'm hosting a game server on my PC is there a way to put on my website if the server is online or offline? Please e-mail me if you know the answer. Posted by: Sebby05 at October 9, 2008 6:31 AMI have something to say, now that you mention it, but ...
I do have a comment, now that you mention it!
|
![]()
Search
Find just the answers you seek from among our 2300+ free tech support articles by using our Lijit search engine.
Help!
Subscribe to
Ask Dave Taylor!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Industry News and Trade Shows Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Book Links
|