hi everybody,
i would like to ask questions regarding bash shell scripting.
but First let me introduce myself.
i am Tiga from amsterdam, and i am kind of new to the programming world.
i have been learning c++ and java.
ive also been using linux a lot lately, and writing lot of perl and bash scripts for my work and private use.
now lets get back to the question.
Question:
i have a function in bash shell that i want to use to check if the given url returns 200 response code or something else. and if the reponse code is 200 then the function should return value 0 for pass and if its anything other than 200 then it should return a value of 1 for fail. How can i do it the best way?.
e.g
----------------------------------------
#!/bin/bash
#cat test.sh
#function
function wgetTest {
wget -nv $1
awk ??
}
#call function and give the variable to work with
>wgetTest Google # expected return value from the function = 0
<0
>wgetTest http://blf909df.difjoij # expected return value from the function = 1
<1
----------------------------------------
Thanks in advance.
Bash Shell, using wget and awk?
Started by TIGA, Apr 11 2008 03:31 PM
1 reply to this topic
#1
Posted 11 April 2008 - 03:31 PM
|
|
|
#2
Posted 26 December 2009 - 09:40 AM
I think you can get this one modified a bit to do what you want.
Simple bash script to monitor your webserver remotely on different ports | Share your knowledge!
Simple bash script to monitor your webserver remotely on different ports | Share your knowledge!


Sign In
Create Account

Back to top









