PDA

Click to See Complete Forum and Search --> : Perl variables ....


visualAd
Jul 6th, 2005, 04:01 AM
Seems like it only takes the first vhost :mad:. It would help if I knew what all these variables in perl meant. :(

<perl>
#!/usr/bin/perl -w
#line <1022>

local ($vhost_dir, $doc_root, $name, $vh);

$vhost_dir = "/home/web";

opendir(VHOSTS, $vhost_dir);

my @file_list = grep(/^[^\.]/,readdir(VHOSTS));
closedir(VHOSTS);

foreach $name (@file_list) {
$doc_root = "$vhost_dir/$name";

if (-d $doc_root) {
$vh={
ServerName => "$name.codedv.com",
DocumentRoot => "$doc_root/htdocs",
SuExecUserGroup => "$name users",
CustomLog => "$doc_root/logs/access_log common",
ErrorLog => "$doc_root/logs/error_log",
ScriptAlias => "/cgi-bin/ $doc_root/cgi-bin/",
Directory => {
"$doc_root/cgi-bin" => {
Options => "+ExecCGI",
Order => "allow,deny",
Allow => "from all"
}
}
};

if (-f "$doc_root/conf/httpd.conf") {
$$vh{Include} = "$doc_root/conf/httpd.conf";
}

$VirtualHost{'10.10.3.2:80'};
}
}
__END__
</perl>

visualAd
Jul 6th, 2005, 04:03 AM
I think I get it now anyway but still no luck ... it seems the its an array and I need to push it on :thinks:

visualAd
Jul 6th, 2005, 04:04 AM
Stupid thing - grrrrrrrrr

<perl>
#!/usr/bin/perl -w
#line <1022>

local ($vhost_dir, $doc_root, $name, $vh);

$vhost_dir = "/home/web";

opendir(VHOSTS, $vhost_dir);

my @file_list = grep(/^[^\.]/,readdir(VHOSTS));
closedir(VHOSTS);

foreach $name (@file_list) {
$doc_root = "$vhost_dir/$name";

if (-d $doc_root) {
$vh={
ServerName => "$name.codedv.com",
DocumentRoot => "$doc_root/htdocs",
SuExecUserGroup => "$name users",
CustomLog => "$doc_root/logs/access_log common",
ErrorLog => "$doc_root/logs/error_log",
ScriptAlias => "/cgi-bin/ $doc_root/cgi-bin/",
Directory => {
"$doc_root/cgi-bin" => {
Options => "+ExecCGI",
Order => "allow,deny",
Allow => "from all"
}
}
}

if (-f "$doc_root/conf/httpd.conf") {
$$vh{Include} = "$doc_root/conf/httpd.conf";
}

push @{ $VirtualHost{'10.10.3.2:80'} }, $vh
}
}
__END__
</perl>

visualAd
Jul 6th, 2005, 04:06 AM
Gottit :D YAYYYYYYY :lol:

<perl>
#!/usr/bin/perl -w
#line <1022>

local ($vhost_dir, $doc_root, $name, $vh);

$vhost_dir = "/home/web";

opendir(VHOSTS, $vhost_dir);

my @file_list = grep(/^[^\.]/,readdir(VHOSTS));
closedir(VHOSTS);

foreach $name (@file_list) {
$doc_root = "$vhost_dir/$name";

if (-d $doc_root) {
$vh={
ServerName => "$name.codedv.com",
DocumentRoot => "$doc_root/htdocs",
SuExecUserGroup => "$name users",
CustomLog => "$doc_root/logs/access_log common",
ErrorLog => "$doc_root/logs/error_log",
ScriptAlias => "/cgi-bin/ $doc_root/cgi-bin/",
Directory => {
"$doc_root/cgi-bin" => {
Options => "+ExecCGI",
Order => "allow,deny",
Allow => "from all"
}
}
};

if (-f "$doc_root/conf/httpd.conf") {
$$vh{Include} = "$doc_root/conf/httpd.conf";
}

push @{ $VirtualHost{'10.10.3.2:80'} }, $vh
}
}
__END__
</perl>

visualAd
Jul 6th, 2005, 04:06 AM
I still havn't got a clue how the variables work but the main thing is it works :D

NoteMe
Jul 6th, 2005, 04:07 AM
Still wrong forum though..:D

visualAd
Jul 6th, 2005, 04:08 AM
You were too slow - I solved my problem now.