LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Need to write a bash script (https://www.linuxquestions.org/questions/linux-general-1/need-to-write-a-bash-script-443081/)

imagineers7 05-09-2006 07:14 AM

Need to write a bash script
 
Hello all,

I wanted to write a bash script which would connect to different mail, ftp, and web servers to make sure those are alive.
I have written a simple script to know if a server is live using ping -c 1 and if exit status is 0 it assumes it is live.
What command I should fire in order to know if smtp, web ,ftp server is alive

Thanks in advance

nx5000 05-09-2006 07:27 AM

Netcat would help you
Code:

echo "quit" | nc $IP ftp
echo -e "HEAD / HTTP/1.0\n\n" | nc $IP www
echo "HELLO" | nc $IP smtp

Then in the responses you should check for a pattern, using sed for example

There are very good pre-made scripts that do this, I am looking in my bookmarks.

imagineers7 05-09-2006 07:34 AM

Hooray NX5000
 
Hats of nx5000,

You have just posted your ONE THOUSAND'TH:twocents: :twocents: :twocents: :twocents: :twocents: :twocents: message
it was lucky me!!!!!!!!!!!!!!!!!!!!!

Thanks for your reply and please find out those scripts for me in your bookmarks,


Thanks for your time again

Dont forget to have a celebration time for your 1000'th post

nx5000 05-09-2006 07:41 AM

Yeah yeah I've just been writing 20 posts in 4 hours to see this number. Now I'm looking for 10000 posts. Until then, the beer will flow!!

Before I get drunk, I think the app is:

swatch http://freshmeat.net/projects/swatch/

I'm not 100% sure its the app I was looking for, there is another one I can't find.. I'll post if I find

Otherwise do your own, using netcat.

ps: imagineers7 , you also have to drink a beer btw :)

nx5000 05-09-2006 07:56 AM

This is the one I was looking for... easy name but hard to remember :)
http://freshmeat.net/projects/checkservice/

imagineers7 05-09-2006 11:17 PM

Hello NX5000,

Thanks for the links.
I thinks checkservice was the thing I was looking for, (although I am going {2 try } to write my own script using nc)
Also found swatch a useful app.

Thanks again, Thanks for your time


_____________________________________
You said:- "was there for 3-4 hours to see the number"
Me:-"was there to be a member"
i.e to cross the figure 30
Beer with double reasons of celebrations!


All times are GMT -5. The time now is 09:26 PM.