Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Sunday, 28 August 2016

check broken link status and result will be store into another file


scripts.sh:
OUTPUT="result.txt"
function test {
 RESPONSE=$(curl -so /dev/null -w "%{http_code}\n" ${1})
 if [[ $RESPONSE != 200 ]]; then
   echo "${RESPONSE} on ${1}" >> $OUTPUT
 fi
}

Create another text file as result.txt where broken urllist will be store.
And one more thing is that all the url that you want to check write into scripts.sh which will be beginging by test as write above in scriipts.sh.


This scripts will be store all the broken urls.

Saturday, 20 August 2016

multiple urls status by single line of code

First check that, Do you have Bash shell:

if you are windows user then goto any directory and then click right button and then select "GIT BASH here" and now you are ready to work.

and if you are linux user then by default you have bash shell, you do not need to worry about this.


Now come to the point:

create new shell by using:
>notepad urls.txt

>function test {
  curl -so /dev/null -w "%{http_code}\t%{url_effective}\t%{redirect_url}\n" ${1}
}  
test "http://google.com"
test "xyz"
.
.
.
.
.
.
.
.
.
and so on.

now save the file.


now run shell script file by
./urls.txt

Congrats you create it successfully.