By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,454 Members | 1,803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,454 IT Pros & Developers. It's quick & easy.

take hostname, look if folder exsist, if not create and copy files

P: n/a
Paw
Greetings.
I use asp.
what I need is is when a visitor comes to the site, I need it to check
the host name. if "www.hometowndigest.com" is the host, then check a
folder named "something" and if the folder does not exsist, create
folder "www" and then copy folder "temp" and its contents.

If the folder "www" is there, look in it, check to see if the files in
folder "temp" are in there, if not, copy the files that are not from
folder "temp" into folder "www".
If instead of www.hometowndigest.com, it is
"vbscript.hometowndigest.com", I need it to do the same rountine. What
ever the subdomain name.
This file will be be drawn as an include file.
NOTE:
1. I do not need it to look in folder "Temp/www" or folder
"temp/vbscript", etc, only folder "temp"
2. Please note further includes along the way in the file will run
script. So, if it could not interfer with those by some kind of
statement.
3. if the host is "hometowndigest.com", or "tn-ol.com", etc, anything,
do nothing.
4. If the script cannot or would be too consuming of time or resources,

maybe i can manually add a listing of the files to look for in the
script through
Thanks in advance.
Paw.

May 29 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
From: "Paul Chambers" <ha******@comcast.net>
Newsgroups: microsoft.public.scripting.vbscript
Subject: Re: create folders and files if...
Date: Tue, 30 May 2006 07:34:56 -0000

Please note I posted this elsewheres. Please anwser at
http://groups.google.com/group/micro...d87b0880a6eda0
I apoligize.
Paul

May 30 '06 #2

P: n/a

Paw wrote:
Greetings.
I use asp.
what I need is is when a visitor comes to the site, I need it to check
the host name. if "www.hometowndigest.com" is the host, then check a
folder named "something" and if the folder does not exsist, create
folder "www" and then copy folder "temp" and its contents.

If the folder "www" is there, look in it, check to see if the files in
folder "temp" are in there, if not, copy the files that are not from
folder "temp" into folder "www".
If instead of www.hometowndigest.com, it is
"vbscript.hometowndigest.com", I need it to do the same rountine. What
ever the subdomain name.
This file will be be drawn as an include file.
NOTE:
1. I do not need it to look in folder "Temp/www" or folder
"temp/vbscript", etc, only folder "temp"
2. Please note further includes along the way in the file will run
script. So, if it could not interfer with those by some kind of
statement.
3. if the host is "hometowndigest.com", or "tn-ol.com", etc, anything,
do nothing.
4. If the script cannot or would be too consuming of time or resources,

maybe i can manually add a listing of the files to look for in the
script through
Thanks in advance.
Paw.


So what is your question? Which bit are you having difficulty with?

--
Mike Brind

May 30 '06 #3

P: n/a
Paw
Thank You for your response.
here is the code I have so far. Not working though. Paul Chambers

<%

'+--------------------------------------------------------------+
'| FOLDERS |
'+--------------------------------------------------------------+

DIM ROOT_PATH : ROOT_PATH = server.MapPath(".")
Dim LOCAL_FOLDER : = Root_path & "\local"

LOCAL_FOLDER = LOCAL_FOLDER & "\" &
mid(Request.ServerVariables("SERVER_NAME"),1 ,instr(1,
Request.ServerVariables("SERVER_NAME"), ".")-1)
'+--------------------------------------------------------------+
'| LOCAL CREATED FILES PATH |
'+--------------------------------------------------------------+
DIM SUB_PATH : SUBL_PATH = ROOT_PATH & LOCAL_PATH & "\default.asp"
DIM OTHERL_PATH : OTHERL_PATH = ROOT_PATH & LOCAL_FOLDER & "\user.asp"


%>

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

'========================================
'---- Checks if the Sub files exist ----
'========================================
' if not copy from the default one
'========================================
'transform that as jscript
Sub CheckAllFiles()
Dim sText
Dim objFSO : Set objFSO =
server.CreateObject("scripting.Filesystemobject")
Dim objFile
Dim arrFolders
Dim arrFiles
Dim i

'We create missing folders
arrFolders = array(LOCAL_FOLDER)
for i=0 to uBound(arrFolders)
If not objFSO.FolderExists(arrFolders(i)) Then
objFSO.CreateFolder(arrFolders(i))
End if
next

'We create missing files
If NOT objFSO.FileExists(SUB_PATH) Then
Set objFile = objFSO.OpenTextFile(ROOT_PATH &
"\secure\master\default.asp", 1)
sText = objFile.ReadAll
Set objFile = nothing

Set objFile = objFSO.CreateTextFile(SUB_PATH, True)
Call objFile.Write(sText)
Set objFile = nothing
End If

If NOT objFSO.FileExists(OTHERL_PATH) Then
Set objFile = objFSO.OpenTextFile(ROOT_PATH & "\secure\master\user.asp",
1)
sText = objFile.ReadAll
Set objFile = nothing

Set objFile = objFSO.CreateTextFile(OTHERL_PATH, True)
Call objFile.Write(sText)
Set objFile = nothing
End If
Set objFSO = nothing

if err<>0 then
err.Clear
Response.Write "<font face=arial><b>Warning :</b> To complete
installation of this SubDomain, you must give write permission to the
database and media directories (under IIS console, and explorer if you use
NTFS).</font>"
Response.End
end if

End Sub
</SCRIPT>

<SCRIPT LANGUAGE="JScript" RUNAT="Server">

//==================================================
// call the vbscrip function with an error trapping
//==================================================
function JSCheckAllFiles()
{
try
{
CheckAllFiles();
}
catch(e) {
Response.Write("<font face=arial><b>Warning :</b> To complete
installation, you must give write permission to the database and media
directories (under IIS console, and explorer if you use NTFS).</font><br>");
return false;
}
}

//==================================================
// Save an SUB file with FSO
//==================================================
function SavesubFile(sFileName, sContent)
{
var objFSO, objFile;

try
{
objFSO = new ActiveXObject("Scripting.FileSystemObject");
objFile = objFSO.CreateTextFile(sFileName, true, true);

}
catch(e) {
Response.AppendToLog("SavesubFile " + e);
Response.Write("<font face=arial><b>Warning :</b> To complete
installation, you must install VBScript runtime version 5.6.</font><br>");
return false;
}
try
{
objFile.Write(sContent);
objFile.close();
}
catch(e) {
Response.AppendToLog("SavesubFile " + e);
Response.Write("<font face=arial><b>Warning :</b> Can't save xml file.
Check the write permission.</font><br>");
//objFile = objFSO.CreateTextFile(sFileName + "." + GetGuid(6), true,
true);
//objFile.Write(sContent);
//objFile.close();
return false;
}

//Response.Write(sFileName + " is updated.<br/>");
}

</SCRIPT>

"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...

Paw wrote:
Greetings.
I use asp.
what I need is is when a visitor comes to the site, I need it to check
the host name. if "www.hometowndigest.com" is the host, then check a
folder named "something" and if the folder does not exsist, create
folder "www" and then copy folder "temp" and its contents.

If the folder "www" is there, look in it, check to see if the files in
folder "temp" are in there, if not, copy the files that are not from
folder "temp" into folder "www".
If instead of www.hometowndigest.com, it is
"vbscript.hometowndigest.com", I need it to do the same rountine. What
ever the subdomain name.
This file will be be drawn as an include file.
NOTE:
1. I do not need it to look in folder "Temp/www" or folder
"temp/vbscript", etc, only folder "temp"
2. Please note further includes along the way in the file will run
script. So, if it could not interfer with those by some kind of
statement.
3. if the host is "hometowndigest.com", or "tn-ol.com", etc, anything,
do nothing.
4. If the script cannot or would be too consuming of time or resources,

maybe i can manually add a listing of the files to look for in the
script through
Thanks in advance.
Paw.


So what is your question? Which bit are you having difficulty with?

--
Mike Brind

May 30 '06 #4

P: n/a
1. How do you define "not work"?
2. Where have you put your response.write statements to check that the
values you expect are actually there?
3. Where are they failing?
4. What error messages do you get, if any?

--
Mike Brind
Paw wrote:
Thank You for your response.
here is the code I have so far. Not working though. Paul Chambers

<%

'+--------------------------------------------------------------+
'| FOLDERS |
'+--------------------------------------------------------------+

DIM ROOT_PATH : ROOT_PATH = server.MapPath(".")
Dim LOCAL_FOLDER : = Root_path & "\local"

LOCAL_FOLDER = LOCAL_FOLDER & "\" &
mid(Request.ServerVariables("SERVER_NAME"),1 ,instr(1,
Request.ServerVariables("SERVER_NAME"), ".")-1)
'+--------------------------------------------------------------+
'| LOCAL CREATED FILES PATH |
'+--------------------------------------------------------------+
DIM SUB_PATH : SUBL_PATH = ROOT_PATH & LOCAL_PATH & "\default.asp"
DIM OTHERL_PATH : OTHERL_PATH = ROOT_PATH & LOCAL_FOLDER & "\user.asp"


%>

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

'========================================
'---- Checks if the Sub files exist ----
'========================================
' if not copy from the default one
'========================================
'transform that as jscript
Sub CheckAllFiles()
Dim sText
Dim objFSO : Set objFSO =
server.CreateObject("scripting.Filesystemobject")
Dim objFile
Dim arrFolders
Dim arrFiles
Dim i

'We create missing folders
arrFolders = array(LOCAL_FOLDER)
for i=0 to uBound(arrFolders)
If not objFSO.FolderExists(arrFolders(i)) Then
objFSO.CreateFolder(arrFolders(i))
End if
next

'We create missing files
If NOT objFSO.FileExists(SUB_PATH) Then
Set objFile = objFSO.OpenTextFile(ROOT_PATH &
"\secure\master\default.asp", 1)
sText = objFile.ReadAll
Set objFile = nothing

Set objFile = objFSO.CreateTextFile(SUB_PATH, True)
Call objFile.Write(sText)
Set objFile = nothing
End If

If NOT objFSO.FileExists(OTHERL_PATH) Then
Set objFile = objFSO.OpenTextFile(ROOT_PATH & "\secure\master\user.asp",
1)
sText = objFile.ReadAll
Set objFile = nothing

Set objFile = objFSO.CreateTextFile(OTHERL_PATH, True)
Call objFile.Write(sText)
Set objFile = nothing
End If
Set objFSO = nothing

if err<>0 then
err.Clear
Response.Write "<font face=arial><b>Warning :</b> To complete
installation of this SubDomain, you must give write permission to the
database and media directories (under IIS console, and explorer if you use
NTFS).</font>"
Response.End
end if

End Sub
</SCRIPT>

<SCRIPT LANGUAGE="JScript" RUNAT="Server">

//==================================================
// call the vbscrip function with an error trapping
//==================================================
function JSCheckAllFiles()
{
try
{
CheckAllFiles();
}
catch(e) {
Response.Write("<font face=arial><b>Warning :</b> To complete
installation, you must give write permission to the database and media
directories (under IIS console, and explorer if you use NTFS).</font><br>");
return false;
}
}

//==================================================
// Save an SUB file with FSO
//==================================================
function SavesubFile(sFileName, sContent)
{
var objFSO, objFile;

try
{
objFSO = new ActiveXObject("Scripting.FileSystemObject");
objFile = objFSO.CreateTextFile(sFileName, true, true);

}
catch(e) {
Response.AppendToLog("SavesubFile " + e);
Response.Write("<font face=arial><b>Warning :</b> To complete
installation, you must install VBScript runtime version 5.6.</font><br>");
return false;
}
try
{
objFile.Write(sContent);
objFile.close();
}
catch(e) {
Response.AppendToLog("SavesubFile " + e);
Response.Write("<font face=arial><b>Warning :</b> Can't save xml file.
Check the write permission.</font><br>");
//objFile = objFSO.CreateTextFile(sFileName + "." + GetGuid(6), true,
true);
//objFile.Write(sContent);
//objFile.close();
return false;
}

//Response.Write(sFileName + " is updated.<br/>");
}

</SCRIPT>

"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...

Paw wrote:
Greetings.
I use asp.
what I need is is when a visitor comes to the site, I need it to check
the host name. if "www.hometowndigest.com" is the host, then check a
folder named "something" and if the folder does not exsist, create
folder "www" and then copy folder "temp" and its contents.

If the folder "www" is there, look in it, check to see if the files in
folder "temp" are in there, if not, copy the files that are not from
folder "temp" into folder "www".
If instead of www.hometowndigest.com, it is
"vbscript.hometowndigest.com", I need it to do the same rountine. What
ever the subdomain name.
This file will be be drawn as an include file.
NOTE:
1. I do not need it to look in folder "Temp/www" or folder
"temp/vbscript", etc, only folder "temp"
2. Please note further includes along the way in the file will run
script. So, if it could not interfer with those by some kind of
statement.
3. if the host is "hometowndigest.com", or "tn-ol.com", etc, anything,
do nothing.
4. If the script cannot or would be too consuming of time or resources,

maybe i can manually add a listing of the files to look for in the
script through
Thanks in advance.
Paw.


So what is your question? Which bit are you having difficulty with?

--
Mike Brind


May 30 '06 #5

P: n/a
Paw
1. How do you define "not work"?

I get server 500 error message., files are not being written.

2. Where have you put your response.write statements to check that the
values you expect are actually there?

The code in the last post is the code I have. If not there, I didn't. I
know the folders and files are there with correct permissions.

3. Where are they failing?

Not sure.

4. What error messages do you get, if any?
Don't have access to my server logs.

I did see one typo in the code, I fixed it. Is it ok to attach a txt file to
the post of the code?

Thank you, Paul Chambers

"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
1. How do you define "not work"?
2. Where have you put your response.write statements to check that the
values you expect are actually there?
3. Where are they failing?
4. What error messages do you get, if any?

--
Mike Brind
Paw wrote:
Thank You for your response.
here is the code I have so far. Not working though. Paul Chambers

<%

'+--------------------------------------------------------------+
'| FOLDERS |
'+--------------------------------------------------------------+

DIM ROOT_PATH : ROOT_PATH = server.MapPath(".")
Dim LOCAL_FOLDER : = Root_path & "\local"

LOCAL_FOLDER = LOCAL_FOLDER & "\" &
mid(Request.ServerVariables("SERVER_NAME"),1 ,instr(1,
Request.ServerVariables("SERVER_NAME"), ".")-1)
'+--------------------------------------------------------------+
'| LOCAL CREATED FILES PATH |
'+--------------------------------------------------------------+
DIM SUB_PATH : SUBL_PATH = ROOT_PATH & LOCAL_PATH & "\default.asp"
DIM OTHERL_PATH : OTHERL_PATH = ROOT_PATH & LOCAL_FOLDER & "\user.asp"


%>

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

'========================================
'---- Checks if the Sub files exist ----
'========================================
' if not copy from the default one
'========================================
'transform that as jscript
Sub CheckAllFiles()
Dim sText
Dim objFSO : Set objFSO =
server.CreateObject("scripting.Filesystemobject")
Dim objFile
Dim arrFolders
Dim arrFiles
Dim i

'We create missing folders
arrFolders = array(LOCAL_FOLDER)
for i=0 to uBound(arrFolders)
If not objFSO.FolderExists(arrFolders(i)) Then
objFSO.CreateFolder(arrFolders(i))
End if
next

'We create missing files
If NOT objFSO.FileExists(SUB_PATH) Then
Set objFile = objFSO.OpenTextFile(ROOT_PATH &
"\secure\master\default.asp", 1)
sText = objFile.ReadAll
Set objFile = nothing

Set objFile = objFSO.CreateTextFile(SUB_PATH, True)
Call objFile.Write(sText)
Set objFile = nothing
End If

If NOT objFSO.FileExists(OTHERL_PATH) Then
Set objFile = objFSO.OpenTextFile(ROOT_PATH &
"\secure\master\user.asp",
1)
sText = objFile.ReadAll
Set objFile = nothing

Set objFile = objFSO.CreateTextFile(OTHERL_PATH, True)
Call objFile.Write(sText)
Set objFile = nothing
End If
Set objFSO = nothing

if err<>0 then
err.Clear
Response.Write "<font face=arial><b>Warning :</b> To complete
installation of this SubDomain, you must give write permission to the
database and media directories (under IIS console, and explorer if you
use
NTFS).</font>"
Response.End
end if

End Sub
</SCRIPT>

<SCRIPT LANGUAGE="JScript" RUNAT="Server">

//==================================================
// call the vbscrip function with an error trapping
//==================================================
function JSCheckAllFiles()
{
try
{
CheckAllFiles();
}
catch(e) {
Response.Write("<font face=arial><b>Warning :</b> To complete
installation, you must give write permission to the database and media
directories (under IIS console, and explorer if you use
NTFS).</font><br>");
return false;
}
}

//==================================================
// Save an SUB file with FSO
//==================================================
function SavesubFile(sFileName, sContent)
{
var objFSO, objFile;

try
{
objFSO = new ActiveXObject("Scripting.FileSystemObject");
objFile = objFSO.CreateTextFile(sFileName, true, true);

}
catch(e) {
Response.AppendToLog("SavesubFile " + e);
Response.Write("<font face=arial><b>Warning :</b> To complete
installation, you must install VBScript runtime version
5.6.</font><br>");
return false;
}
try
{
objFile.Write(sContent);
objFile.close();
}
catch(e) {
Response.AppendToLog("SavesubFile " + e);
Response.Write("<font face=arial><b>Warning :</b> Can't save xml file.
Check the write permission.</font><br>");
//objFile = objFSO.CreateTextFile(sFileName + "." + GetGuid(6), true,
true);
//objFile.Write(sContent);
//objFile.close();
return false;
}

//Response.Write(sFileName + " is updated.<br/>");
}

</SCRIPT>

"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
>
> Paw wrote:
>> Greetings.
>> I use asp.
>> what I need is is when a visitor comes to the site, I need it to check
>> the host name. if "www.hometowndigest.com" is the host, then check a
>> folder named "something" and if the folder does not exsist, create
>> folder "www" and then copy folder "temp" and its contents.
>>
>> If the folder "www" is there, look in it, check to see if the files in
>> folder "temp" are in there, if not, copy the files that are not from
>> folder "temp" into folder "www".
>>
>>
>> If instead of www.hometowndigest.com, it is
>> "vbscript.hometowndigest.com", I need it to do the same rountine. What
>> ever the subdomain name.
>>
>>
>> This file will be be drawn as an include file.
>>
>>
>> NOTE:
>>
>>
>> 1. I do not need it to look in folder "Temp/www" or folder
>> "temp/vbscript", etc, only folder "temp"
>> 2. Please note further includes along the way in the file will run
>> script. So, if it could not interfer with those by some kind of
>> statement.
>> 3. if the host is "hometowndigest.com", or "tn-ol.com", etc, anything,
>> do nothing.
>> 4. If the script cannot or would be too consuming of time or
>> resources,
>>
>> maybe i can manually add a listing of the files to look for in the
>> script through
>>
>>
>> Thanks in advance.
>> Paw.
>
> So what is your question? Which bit are you having difficulty with?
>
> --
> Mike Brind
>

May 30 '06 #6

P: n/a
What is the server 500 message and which line does it refer to?

--
Mike Brind

Paw wrote:
1. How do you define "not work"?

I get server 500 error message., files are not being written.

2. Where have you put your response.write statements to check that the
values you expect are actually there?

The code in the last post is the code I have. If not there, I didn't. I
know the folders and files are there with correct permissions.

3. Where are they failing?

Not sure.

4. What error messages do you get, if any?
Don't have access to my server logs.

I did see one typo in the code, I fixed it. Is it ok to attach a txt file to
the post of the code?

Thank you, Paul Chambers

"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
1. How do you define "not work"?
2. Where have you put your response.write statements to check that the
values you expect are actually there?
3. Where are they failing?
4. What error messages do you get, if any?

--
Mike Brind
Paw wrote:
Thank You for your response.
here is the code I have so far. Not working though. Paul Chambers

<%

'+--------------------------------------------------------------+
'| FOLDERS |
'+--------------------------------------------------------------+

DIM ROOT_PATH : ROOT_PATH = server.MapPath(".")
Dim LOCAL_FOLDER : = Root_path & "\local"

LOCAL_FOLDER = LOCAL_FOLDER & "\" &
mid(Request.ServerVariables("SERVER_NAME"),1 ,instr(1,
Request.ServerVariables("SERVER_NAME"), ".")-1)
'+--------------------------------------------------------------+
'| LOCAL CREATED FILES PATH |
'+--------------------------------------------------------------+
DIM SUB_PATH : SUBL_PATH = ROOT_PATH & LOCAL_PATH & "\default.asp"
DIM OTHERL_PATH : OTHERL_PATH = ROOT_PATH & LOCAL_FOLDER & "\user.asp"


%>

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">

'========================================
'---- Checks if the Sub files exist ----
'========================================
' if not copy from the default one
'========================================
'transform that as jscript
Sub CheckAllFiles()
Dim sText
Dim objFSO : Set objFSO =
server.CreateObject("scripting.Filesystemobject")
Dim objFile
Dim arrFolders
Dim arrFiles
Dim i

'We create missing folders
arrFolders = array(LOCAL_FOLDER)
for i=0 to uBound(arrFolders)
If not objFSO.FolderExists(arrFolders(i)) Then
objFSO.CreateFolder(arrFolders(i))
End if
next

'We create missing files
If NOT objFSO.FileExists(SUB_PATH) Then
Set objFile = objFSO.OpenTextFile(ROOT_PATH &
"\secure\master\default.asp", 1)
sText = objFile.ReadAll
Set objFile = nothing

Set objFile = objFSO.CreateTextFile(SUB_PATH, True)
Call objFile.Write(sText)
Set objFile = nothing
End If

If NOT objFSO.FileExists(OTHERL_PATH) Then
Set objFile = objFSO.OpenTextFile(ROOT_PATH &
"\secure\master\user.asp",
1)
sText = objFile.ReadAll
Set objFile = nothing

Set objFile = objFSO.CreateTextFile(OTHERL_PATH, True)
Call objFile.Write(sText)
Set objFile = nothing
End If
Set objFSO = nothing

if err<>0 then
err.Clear
Response.Write "<font face=arial><b>Warning :</b> To complete
installation of this SubDomain, you must give write permission to the
database and media directories (under IIS console, and explorer if you
use
NTFS).</font>"
Response.End
end if

End Sub
</SCRIPT>

<SCRIPT LANGUAGE="JScript" RUNAT="Server">

//==================================================
// call the vbscrip function with an error trapping
//==================================================
function JSCheckAllFiles()
{
try
{
CheckAllFiles();
}
catch(e) {
Response.Write("<font face=arial><b>Warning :</b> To complete
installation, you must give write permission to the database and media
directories (under IIS console, and explorer if you use
NTFS).</font><br>");
return false;
}
}

//==================================================
// Save an SUB file with FSO
//==================================================
function SavesubFile(sFileName, sContent)
{
var objFSO, objFile;

try
{
objFSO = new ActiveXObject("Scripting.FileSystemObject");
objFile = objFSO.CreateTextFile(sFileName, true, true);

}
catch(e) {
Response.AppendToLog("SavesubFile " + e);
Response.Write("<font face=arial><b>Warning :</b> To complete
installation, you must install VBScript runtime version
5.6.</font><br>");
return false;
}
try
{
objFile.Write(sContent);
objFile.close();
}
catch(e) {
Response.AppendToLog("SavesubFile " + e);
Response.Write("<font face=arial><b>Warning :</b> Can't save xml file.
Check the write permission.</font><br>");
//objFile = objFSO.CreateTextFile(sFileName + "." + GetGuid(6), true,
true);
//objFile.Write(sContent);
//objFile.close();
return false;
}

//Response.Write(sFileName + " is updated.<br/>");
}

</SCRIPT>

"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
>
> Paw wrote:
>> Greetings.
>> I use asp.
>> what I need is is when a visitor comes to the site, I need it to check
>> the host name. if "www.hometowndigest.com" is the host, then check a
>> folder named "something" and if the folder does not exsist, create
>> folder "www" and then copy folder "temp" and its contents.
>>
>> If the folder "www" is there, look in it, check to see if the files in
>> folder "temp" are in there, if not, copy the files that are not from
>> folder "temp" into folder "www".
>>
>>
>> If instead of www.hometowndigest.com, it is
>> "vbscript.hometowndigest.com", I need it to do the same rountine. What
>> ever the subdomain name.
>>
>>
>> This file will be be drawn as an include file.
>>
>>
>> NOTE:
>>
>>
>> 1. I do not need it to look in folder "Temp/www" or folder
>> "temp/vbscript", etc, only folder "temp"
>> 2. Please note further includes along the way in the file will run
>> script. So, if it could not interfer with those by some kind of
>> statement.
>> 3. if the host is "hometowndigest.com", or "tn-ol.com", etc, anything,
>> do nothing.
>> 4. If the script cannot or would be too consuming of time or
>> resources,
>>
>> maybe i can manually add a listing of the files to look for in the
>> script through
>>
>>
>> Thanks in advance.
>> Paw.
>
> So what is your question? Which bit are you having difficulty with?
>
> --
> Mike Brind
>


May 31 '06 #7

P: n/a
Paw
Thanks for you help, Mike. The last post you sent made me think to stop and
start over, which I did. I came up with some code that will work.

I have inserted it below.

Basically, for any whose interested, I give am getting ready to give away
blogging sites, with upgradable features for a small cost. I needed away to
setup up the new users without cost or labor by our team, except for after
setup tech supports and upgrades. My team as well as myself are all
disabled, web enabled. So lower costs are important. We are wildcarding
several domains to widen our reach. Tn-ol.com, hometowndigest.com,
thatinternetplace.com.

I have a package of asp scipts for the new users. Just needed a scalable
deployment system.

So to close, I just needed to create new folders based on subdomain, and
then copy a template folder. This is generic. I will implement it into my
secure pages until I start from scratch.

Below is the code.

I haven't done coding in years, and forgot alot. But its coming back to me.
If you could guide me in one more way, I would appreciate it. It probably is
novice but I can't seem to remember it all yet.

I would like to run more script from the setup page. what would the script
setup be for doing the next routine after this one. In the code below,
instead of "bye", "I would like to say and "now I am doing something else,
hold on " run the next script and so on until the final.

Have a good day..
Paul Chambers

'start code-----

Hello. I am creating client folders <br>
please Stand By while I create your folders and files.<br><img
src=status.gif><br>

<%
dim fs,fo
SUBDONO=""
SUBDOYES=mid(Request.ServerVariables("SERVER_NAME" ),1 ,instr(1,
Request.ServerVariables("SERVER_NAME"), ".")-1)

if inStr (SUBDOYES,SUBDONO)=1 then
set fs=Server.CreateObject("Scripting.FileSystemObject ")
set fo=fs.GetFolder("put path to template folder in the form of
E:\something\template")
fo.Copy("D:\something\client\files\" & SUBDOYES)
set fo=nothing
set fs=nothing
else
end if
%>
ok, I am done. Bye.
'end code

"Paw" <ha******@comcast.net> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
Greetings.
I use asp.
what I need is is when a visitor comes to the site, I need it to check
the host name. if "www.hometowndigest.com" is the host, then check a
folder named "something" and if the folder does not exsist, create
folder "www" and then copy folder "temp" and its contents.

If the folder "www" is there, look in it, check to see if the files in
folder "temp" are in there, if not, copy the files that are not from
folder "temp" into folder "www".
If instead of www.hometowndigest.com, it is
"vbscript.hometowndigest.com", I need it to do the same rountine. What
ever the subdomain name.
This file will be be drawn as an include file.
NOTE:
1. I do not need it to look in folder "Temp/www" or folder
"temp/vbscript", etc, only folder "temp"
2. Please note further includes along the way in the file will run
script. So, if it could not interfer with those by some kind of
statement.
3. if the host is "hometowndigest.com", or "tn-ol.com", etc, anything,
do nothing.
4. If the script cannot or would be too consuming of time or resources,

maybe i can manually add a listing of the files to look for in the
script through
Thanks in advance.
Paw.

May 31 '06 #8

P: n/a
Paw
It didnt say. I was on IE 7 beta. I sent the last message before this one.
sorry..
"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11**********************@h76g2000cwa.googlegr oups.com...
What is the server 500 message and which line does it refer to?

--
Mike Brind

Paw wrote:
1. How do you define "not work"?

I get server 500 error message., files are not being written.

2. Where have you put your response.write statements to check that the
values you expect are actually there?

The code in the last post is the code I have. If not there, I didn't. I
know the folders and files are there with correct permissions.

3. Where are they failing?

Not sure.

4. What error messages do you get, if any?
Don't have access to my server logs.

I did see one typo in the code, I fixed it. Is it ok to attach a txt file
to
the post of the code?

Thank you, Paul Chambers

"Mike Brind" <pa*******@hotmail.com> wrote in message
news:11**********************@j73g2000cwa.googlegr oups.com...
> 1. How do you define "not work"?
> 2. Where have you put your response.write statements to check that the
> values you expect are actually there?
> 3. Where are they failing?
> 4. What error messages do you get, if any?
>
> --
> Mike Brind
>
>
> Paw wrote:
>> Thank You for your response.
>> here is the code I have so far. Not working though. Paul Chambers
>>
>> <%
>>
>> '+--------------------------------------------------------------+
>> '| FOLDERS |
>> '+--------------------------------------------------------------+
>>
>> DIM ROOT_PATH : ROOT_PATH = server.MapPath(".")
>> Dim LOCAL_FOLDER : = Root_path & "\local"
>>
>> LOCAL_FOLDER = LOCAL_FOLDER & "\" &
>> mid(Request.ServerVariables("SERVER_NAME"),1 ,instr(1,
>> Request.ServerVariables("SERVER_NAME"), ".")-1)
>>
>>
>> '+--------------------------------------------------------------+
>> '| LOCAL CREATED FILES PATH |
>> '+--------------------------------------------------------------+
>> DIM SUB_PATH : SUBL_PATH = ROOT_PATH & LOCAL_PATH & "\default.asp"
>> DIM OTHERL_PATH : OTHERL_PATH = ROOT_PATH & LOCAL_FOLDER &
>> "\user.asp"
>>
>>
>>
>>
>> %>
>>
>> <SCRIPT LANGUAGE="VBScript" RUNAT="Server">
>>
>>
>>
>> '========================================
>> '---- Checks if the Sub files exist ----
>> '========================================
>> ' if not copy from the default one
>> '========================================
>> 'transform that as jscript
>> Sub CheckAllFiles()
>> Dim sText
>> Dim objFSO : Set objFSO =
>> server.CreateObject("scripting.Filesystemobject")
>> Dim objFile
>> Dim arrFolders
>> Dim arrFiles
>> Dim i
>>
>> 'We create missing folders
>> arrFolders = array(LOCAL_FOLDER)
>> for i=0 to uBound(arrFolders)
>> If not objFSO.FolderExists(arrFolders(i)) Then
>> objFSO.CreateFolder(arrFolders(i))
>> End if
>> next
>>
>> 'We create missing files
>> If NOT objFSO.FileExists(SUB_PATH) Then
>> Set objFile = objFSO.OpenTextFile(ROOT_PATH &
>> "\secure\master\default.asp", 1)
>> sText = objFile.ReadAll
>> Set objFile = nothing
>>
>> Set objFile = objFSO.CreateTextFile(SUB_PATH, True)
>> Call objFile.Write(sText)
>> Set objFile = nothing
>> End If
>>
>> If NOT objFSO.FileExists(OTHERL_PATH) Then
>> Set objFile = objFSO.OpenTextFile(ROOT_PATH &
>> "\secure\master\user.asp",
>> 1)
>> sText = objFile.ReadAll
>> Set objFile = nothing
>>
>> Set objFile = objFSO.CreateTextFile(OTHERL_PATH, True)
>> Call objFile.Write(sText)
>> Set objFile = nothing
>> End If
>>
>>
>> Set objFSO = nothing
>>
>> if err<>0 then
>> err.Clear
>> Response.Write "<font face=arial><b>Warning :</b> To complete
>> installation of this SubDomain, you must give write permission to the
>> database and media directories (under IIS console, and explorer if you
>> use
>> NTFS).</font>"
>> Response.End
>> end if
>>
>> End Sub
>>
>>
>> </SCRIPT>
>>
>>
>>
>> <SCRIPT LANGUAGE="JScript" RUNAT="Server">
>>
>> //==================================================
>> // call the vbscrip function with an error trapping
>> //==================================================
>> function JSCheckAllFiles()
>> {
>> try
>> {
>> CheckAllFiles();
>> }
>> catch(e) {
>> Response.Write("<font face=arial><b>Warning :</b> To complete
>> installation, you must give write permission to the database and media
>> directories (under IIS console, and explorer if you use
>> NTFS).</font><br>");
>> return false;
>> }
>> }
>>
>> //==================================================
>> // Save an SUB file with FSO
>> //==================================================
>> function SavesubFile(sFileName, sContent)
>> {
>> var objFSO, objFile;
>>
>> try
>> {
>> objFSO = new ActiveXObject("Scripting.FileSystemObject");
>> objFile = objFSO.CreateTextFile(sFileName, true, true);
>>
>> }
>> catch(e) {
>> Response.AppendToLog("SavesubFile " + e);
>> Response.Write("<font face=arial><b>Warning :</b> To complete
>> installation, you must install VBScript runtime version
>> 5.6.</font><br>");
>> return false;
>> }
>>
>>
>> try
>> {
>> objFile.Write(sContent);
>> objFile.close();
>> }
>> catch(e) {
>> Response.AppendToLog("SavesubFile " + e);
>> Response.Write("<font face=arial><b>Warning :</b> Can't save xml
>> file.
>> Check the write permission.</font><br>");
>> //objFile = objFSO.CreateTextFile(sFileName + "." + GetGuid(6),
>> true,
>> true);
>> //objFile.Write(sContent);
>> //objFile.close();
>> return false;
>> }
>>
>> //Response.Write(sFileName + " is updated.<br/>");
>> }
>>
>> </SCRIPT>
>>
>>
>>
>>
>>
>> "Mike Brind" <pa*******@hotmail.com> wrote in message
>> news:11**********************@j73g2000cwa.googlegr oups.com...
>> >
>> > Paw wrote:
>> >> Greetings.
>> >> I use asp.
>> >> what I need is is when a visitor comes to the site, I need it to
>> >> check
>> >> the host name. if "www.hometowndigest.com" is the host, then check
>> >> a
>> >> folder named "something" and if the folder does not exsist, create
>> >> folder "www" and then copy folder "temp" and its contents.
>> >>
>> >> If the folder "www" is there, look in it, check to see if the files
>> >> in
>> >> folder "temp" are in there, if not, copy the files that are not
>> >> from
>> >> folder "temp" into folder "www".
>> >>
>> >>
>> >> If instead of www.hometowndigest.com, it is
>> >> "vbscript.hometowndigest.com", I need it to do the same rountine.
>> >> What
>> >> ever the subdomain name.
>> >>
>> >>
>> >> This file will be be drawn as an include file.
>> >>
>> >>
>> >> NOTE:
>> >>
>> >>
>> >> 1. I do not need it to look in folder "Temp/www" or folder
>> >> "temp/vbscript", etc, only folder "temp"
>> >> 2. Please note further includes along the way in the file will run
>> >> script. So, if it could not interfer with those by some kind of
>> >> statement.
>> >> 3. if the host is "hometowndigest.com", or "tn-ol.com", etc,
>> >> anything,
>> >> do nothing.
>> >> 4. If the script cannot or would be too consuming of time or
>> >> resources,
>> >>
>> >> maybe i can manually add a listing of the files to look for in the
>> >> script through
>> >>
>> >>
>> >> Thanks in advance.
>> >> Paw.
>> >
>> > So what is your question? Which bit are you having difficulty with?
>> >
>> > --
>> > Mike Brind
>> >
>

May 31 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.