473,320 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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
8 2545
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

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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mario T. Lanza | last post by:
I am working with Visual Studio. The solution I am developing is composed of about 8 separate projects. Some of these projects represent different tiers in the N-tiered architecture (data,...
1
by: Antonio Lopez Arredondo | last post by:
hi all !!! I need to copy a folder and its subfolders to another location; which class should I use ? could only find the System.IO.Directory.MOVE but don't know how to COPY. thanks in...
3
by: nate | last post by:
I created a performance evaluation for our employees on our web server in a folder called 'performanceEval'. Now I wanted to create a slightly modified version for supervisors. I made a new folder...
2
by: tatemononai | last post by:
Ok, this is a very unique bug. I have only been able to find one other post related to this online, and everybody who responded misunderstood the problem. I am not trying to reference anything in...
17
by: rdemyan via AccessMonster.com | last post by:
With A2003, I'm having trouble accessing files in a folder on another computer where back-end files, update files, etc are located. Here's the scenario: 1) Computer #1 - A2003 2) Computer #2 -...
1
by: halcyon943 | last post by:
have 4 folders that I watch and need to move files from to another location. Three constraints: -Finish time. Make sure the program stops transferring files at a specific time -Number of...
4
by: supriyamk | last post by:
Hi, I am trying to search a directory for subdirectories, recreate the subdirectories elsewhere and copy only certain files from current subdirectory to new subdirectory. In other words i am...
2
by: swethak | last post by:
hi, i want to copy the contents of one folder into another folder.For that i create the one new folder . I copied the files of already existing folder into new folder.For that i write a code as...
9
by: Keith G Hicks | last post by:
I'm having a lot of trouble with "file in use" errors in my "folder watcher" project. Starting and stopping the watcher and reading my XML file work fine. Once the watcher is started, I'm reading...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.