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

**NEWBIE FileGrep QUESTION***


2 replies to this topic

is_support

is_support
  • Members
  • 2 posts

Posted 16 September 2004 - 20:18

**NEWBIE QUESTION**

I have a question regarding variable replacement in a text file. In this instance, I am prompting the user for IP address and Port number, and have created dialogs for that. I have defined variables in the InstallScript to hold those values for later use. The intention is to take those values and insert them into an IIS "web.config" file.

Inside of this file I have the replacable text in this form exactly:

<add key="LoginMode" value="[SITETYPE]" />

The [SITETYPE] reflects a variable defined in the script and is tied to the Setup Type. Overall, the setup runs fine except the variables do not get replaced in the script. I do not know what I am doing wrong. (See script segments below).


///////////////////////////////////////////////////////////////////////////////////

#define DEFAULT_IPADDRESS "0.0.0.0"
#define DEFAULT_PORT "0000"
#define SETUPTYPE1 "VA"
#define SETUPTYPE2 "COMMERCIAL"
#define SETUPTYPE_TITLE "Wireless BloodCare Installation"
#define SETUPTYPE_MSG "Please select your setup type based on your environment."
#define SOURCE_DIR "C:\inetpub\wwwroot\WBCServices\\"
#define SOURCE_FILE "web.config"

/////////////////////////////////////////////////////////////////////////////////////////


// setup default status
Enable(STATUSEX);
return 0;

//////////////////////////////////////////////////////////////////////////////////
//Begin the String replacement in neccessary config file.// //
// //
// The following function will configure the "\WBCServices\web.config" file //
// based on values given by the user. It will configure for VA or Commercial //
// the appropriate Authentication service and add additional information per //
// the developer release notes. //
// //
//////////////////////////////////////////////////////////////////////////////////

//Find and replace operation 1: SITETYPE

FileGrep ( SOURCE_DIR ^ SOURCE_FILE , "[SITETYPE]" , svReturnLine , nvLineNumber , RESTART );
nLength = StrLengthChars( svReturnLine );
nStart = StrLengthChars( "<add key=\"LoginMode\" value=\"svSiteType\"/>");

//Find and replace operation 2: SERVERIP

FileGrep ( SOURCE_DIR ^ SOURCE_FILE , "[SERVERIP]" , svReturnLine , nvLineNumber , RESTART );
nLength = StrLengthChars( svReturnLine );
nStart = StrLengthChars( "<add key=\"VistaServer\" value=\"svIP\"/>");

//Find and replace operation 3: SERVERPORT

FileGrep ( SOURCE_DIR ^ SOURCE_FILE , "[SERVERPORT]" , svReturnLine , nvLineNumber , RESTART );
nLength = StrLengthChars( svReturnLine );
nStart = StrLengthChars( "<add key=\"VistaPort\" value=\"svPort\"/>");

// Close the file.
if (CloseFile (nvFileHandle) < 0) then
MessageBox ("CloseFile failed.", SEVERE);
end;
/////////////////////////////////////////////////////////////////////////////

If anyone can help, I would appreciate it.

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 17 September 2004 - 13:24

This should be:
#define SOURCE_DIR "C:\\inetpub\\wwwroot\\WBCServices\\"

Also I don't see where you are actually replacing the text?

You may also want to look at the sample code "Replace a String in a File" at http://www.installsi.../en/isp_str.htm

is_support

is_support
  • Members
  • 2 posts

Posted 17 September 2004 - 13:31

Thanks Stefan, I'll try that out shortly. It makes sense that if IS can't find the right file no edits can be made...