Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Walking thru a list to find a SubStr of a Str


5 replies to this topic

jwendel

jwendel
  • Members
  • 3 posts

Posted 06 January 2003 - 22:38

Does anyone know how to walk thru a list to find a SubStr of a Str and then check to see if that string is equal to a string that was inputted by the user?


Thanks

hambone

hambone
  • Members
  • 206 posts

Posted 07 January 2003 - 14:01

could you tell me what development lanaguage you want to use ( am assuming IS Scripting but will vba or vb be okay ? ) and how is the list created ?

jwendel

jwendel
  • Members
  • 3 posts

Posted 07 January 2003 - 15:52

Here is the scenario,
I have a config file that I write environment names to after the user inputs them.  The config file also has other variables like database names, etc.  I want to do a Global Search and check the config file to make sure the names do not match.  Do you think it is best to read the file into a list, and then grep the list, or just grep the config file and so on.  

I am using InstallScript.   I also have another question.  Do you know how to configure a website for IIS through InstallScript?  I think you can use VBScript.  But I am not sure as to go through the rest..
Thanks ???

hambone

hambone
  • Members
  • 206 posts

Posted 07 January 2003 - 20:00

i would be tempted to use a vb/vbs/vba ca to read the file and parse the input text...

simple searches can be performed by shelling to dos ( a slow process by relative terms ) and using the find command...

cmcintosh

cmcintosh
  • Members
  • 7 posts

Posted 23 January 2003 - 17:43

These are functions I use to access config files with data such as

variablename=value

the second one is faster but I've run into sporadic problems with batchfileload crashing for no reason here and there.
I'm not sure what exactly you're trying to do but I do a lot with text files and could probably help.

function GetConfigVarInfo( szConfigFile, szVariable, szInfo )    

STRING szLT;
NUMBER nResult, nPos,nLine;

begin
nResult=FileGrep(szConfigFile,szVariable,szLT,nLine,RESTART);
if(nResult=0)then
//Parse the data Look for the '=' sign
nPos = StrFind( szLT, "=" );
if( nPos >= 0 ) then
   if( StrSub( szInfo, szLT, nPos + 1, StrLength( szLT ) - nPos - 1 ) > 0 ) then
       nResult = 0;
   endif;    
else
   return nPos;
endif;
endif;
return nResult;

end;

function GetConfigVarInfo( szConfigFile, szVariable,szInfo )    

STRING szLT;
NUMBER nResult, nPos;

begin

szInfo = "";
nResult = BatchFileLoad( szConfigFile );
if( !nResult ) then
nResult = BatchFind( szVariable, szLT, COMMAND|RESTART );

//Parse the data
//Look for the '=' sign
nPos = StrFind( szLT, "=" );
if( nPos >= 0 ) then
   if( StrSub( szInfo, szLT, nPos + 1, StrLength( szLT ) - nPos - 1 ) > 0 ) then
       nResult = 0;
   endif;    
else
   return nPos;
endif;
endif;

return nResult;

end;

cmcintosh

cmcintosh
  • Members
  • 7 posts

Posted 23 January 2003 - 17:45

This is vb script to create a website.  name the script something.vbs and run it with wscript or cscript passing it the name of the folder you wish to convert the folder should preferably be in wwwroot.
'
' Script for use on an IIS system to create a new web site.
' The name and path of the web site are specified on the command line
' as the first and second arguments (respectively) after the script name.
' The path should be specified as a virtual path, and must already exist.
'

Option Explicit

Const INPROC = True
Const OUTPROC = False

Dim FSO      ' FileSystemObject used to create physical directory for web app
Dim IISPath  ' IIS Metabase path used to access virtual directory for web app
Dim AppName  ' Name of new web app
Dim AppPath  ' Virtual directory where new web app should be installed (must exist)
Dim SysPath  ' Local filesystem path corresponding to AppPath (calculated)

If wscript.arguments.count < 1 Then
  wscript.echo "Usage: CreateWebApp <AppName> [<App Path>]" & vbCrLf & _
     "Where: <App Path> Is relative to Default Web Site/" & vbCrLf & _
     "<AppName> is installed as its own directory *under* <App Path>"
  wscript.quit(1)
End If
AppName = wscript.arguments(0)
If wscript.arguments.count>=2 Then
  AppPath = wscript.arguments(1)
  If Left(AppPath,1) <> "/" Then AppPath = "/" & AppPath
Else
  AppPath = ""
End If
If Right(AppPath,1) = "/" or Right(AppPath,1) = "\" Then
  AppPath = Left(AppPath,Len(AppPath)-1)
End If
If Left(AppPath, 3)="/.." Then
  wscript.echo "Cannot install above web root"
  wscript.quit(1)
End If

' This is used to find the physical path where the new app needs to be created
Set IISPath = GetObject("IIS://LocalHost/W3svc/1/ROOT" & AppPath)

SysPath = GetIIsWebDirectoryPath(IISPath)

' Create the physical directory if it doesn't already exist
Set FSO = CreateObject("Scripting.FileSystemObject")
If Not(FSO.FolderExists(SysPath & "\" & AppName)) Then
  FSO.CreateFolder SysPath & "\" & AppName
End If

' The folder has been created in the file system, but needs to be created in the metabase
On Error Resume Next ' It might already exist in the metabase, this would cause an error
Set IISPath = IISPath.Create("IIsWebDirectory", AppName)
If Err.Number <> 0 Then
  Set IISPath = GetObject("IIS://LocalHost/W3svc/1/ROOT" & AppPath & "/" & AppName)
Else
  IISPath.SetInfo
End If
On Error Goto 0
IISPath.AppCreate OUTPROC
IISPath.SetInfo

Function GetIIsWebDirectoryPath(WebDirObj)
  Dim oPrnt
  If WebDirObj.Class <> "IIsWebVirtualDir" Then
     Set oPrnt = GetObject(WebDirObj.Parent)
     If oPrnt.Class = "IIsWebServer" Then
        ' This happens in rare cases in IIS4 -- no virtual directory
        ' is defined so we need to get it from the registry
        GetIIsWebDirectoryPath = WScript.CreateObject("WScript.Shell").RegRead("HKLM\Software\Microsoft\InetStp\PathWWWRoot")
     Else
        GetIIsWebDirectoryPath = GetIISWebDirectoryPath(oPrnt) & "\" & WebDirObj.Name
     End If
  Else
     GetIIsWebDirectoryPath = WebDirObj.Path
  End If
End Function