Dear Niyati,
Greetings from CodeLogic !!
Here's your solution !!
[root@desktop8 ~]# cat test.sh
#!/bin/bash
echo "Enter Directory Name"
# Get the input from the user
read -p "Directory Name: " DIR
# To check whether the directory exists
if [ -d /apache/htdocs/$DIR ];
then
echo "$DIR directory exists"
else
mkdir -p /apache/htdocs/$DIR
fi
# Now we start our loop to create symbolic links !!
for link in $(cat /root/hostlist)
do
#first we check whether the link exists !!
if [ -L /apache/htdocs/$link/$DIR ];
then
echo "$DIR link exists"
else
ln -s /apache/htdocs/$DIR /apache/htdocs/$link/$DIR
fi
done
Deep Patel ( RHC{X,I,SS,VA,DS}, CCNA, CE|H )
CodeLogic
C/3, Sandeep Appartments,
Opp Windsor Plaza, R.C.Dutt Road,
Alkapuri, Vadodara 390007
www.codelogic.co.in
M:
+91 9601009898
On Mar 5, 5:45 pm, Niyati Dave <
niyati...@gmail.com> wrote:
> Hi Sir,
> Did you check?
>
> Hello all,
> can anyone else give some idea on this... ?
>
> > On Fri, Mar 2, 2012 at 5:46 PM, Niyati Dave <
niyati...@gmail.com> wrote:
>
> >> Hi Sir... thanks for trying that....
>
> >> can you please try one more thing just to reproduce the problem. (For me
> >> it happens every time... not only in second attempt... )
>
> >> you entered the directory name 'example'. please try to run the same
> >> script again with the same dir name 'example'... it should give error for
> >> all the
> >> "ln -s .. " statements...
> >> but also it creates the symbolic link with itself like if you look into
> >> cd /apache/htdocs/example
> >> ls -l
> >> example -> /apache/htdocs/example
>
> >> There will be a symbolic link created with itself.. This is the actual
> >> problem.... I want to get rid of .
>
> >> Thanks
> >> Niyati
>
> >> On Fri, Mar 2, 2012 at 8:57 AM, ElectroMech <
electrom...@electromech.info
> >> > wrote:
>
> >>> On Thu, Mar 1, 2012 at 3:53 PM, Niyati Dave <
niyati...@gmail.com> wrote:
>
> >>>> Hi
>
> >>>>> In the file name list suppose there is a list of virtual hosts, I want
> >>>>> that any new directory in main htdocs should have its symlink in each of
> >>>>> the vhosts
>
> >>>>> cat list
>
> >>>>> vhost1
> >>>>> vhost2
> >>>>> vhost3
> >>>>> ....
>
> >>> I think your requirement is mass virtual hosting, this can be done with
> >>> apache configuration itself.
>
> >>> Please check the following link
>
> >>>
http://httpd.apache.org/docs/2.4/vhosts/mass.html
>
> >>> Dynamically Configured Mass Virtual Hosting
>
> >>> Available Languages: en <
http://httpd.apache.org/docs/2.4/en/vhosts/mass.html>|
> >>> fr <
http://httpd.apache.org/docs/2.4/fr/vhosts/mass.html> | ko <
http://httpd.apache.org/docs/2.4/ko/vhosts/mass.html>|
> >>> tr <
http://httpd.apache.org/docs/2.4/tr/vhosts/mass.html>
>
> >>> This document describes how to efficiently serve an arbitrary number of
> >>> virtual hosts with the Apache HTTP Server. A separate document<
http://httpd.apache.org/docs/2.4/rewrite/vhosts.html>discusses using
> >>> mod_rewrite <
http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html> to