I am trying to write a shell script to check for the existence of a particular directory in a particular domain name. For example, I have a web site named www.example.com
. I want to check whether the page www.example.com/testpage
exists or not. I have a text file containing a list of directory names,one per line, which must be replaced with the name testpage
. I want the script to select each of these directory names,append it to the url www.example.com
and validate it. How can I begin writing my script?
Let's examine an example.
File
relative_urls.list
:We'd like to check if these documents available on the site http://askubuntu.com.
Possible solution:
And the result is:
If you prefer another definition of availability of url, you can change
grep
command to something more relevant to your conditions.Important thing is that
curl
shows whether an url is served by a web server. There is no reliable method to determine existence of directory on a web server's file system via http.