SPONSORS:






User Tag List

Results 1 to 3 of 3
  1. #1
    Guest

    Open file in Read and write mode

    I want to copy a batch file to a remote machine whenever I run the install script to test installation of a product is success/fail.
    The batch file has the following command:
    *****************************
    c:\<companyname>\install\bin\jview -cp "c:\<companyname>\install\lib\custom.zip ;" test.Load -D default -v c:\mssql\binn

    *****************************
    In the above command c:\<companyname>\install changes depending on the person installing the product upon running the script. Also c:\mssql\binn changes from machine to machine.
    I have to open a file in (Read | Write) mode so that I can read the whole command and replace necessary values by writing into the file. I tried with update mode, but I could'nt do it.

    Thanks
    Rameswara R. Kamani

  2. #2
    Guest

    Re: Open file in Read and write mode

    Rameswara,

    One solution we have found particularly helpful in making scripts portable
    is to write variable values to an ini file that can be edited prior to
    running scripts and suites. In this file you can include any value that
    makes your script machine or user specific. Our theory is that the script
    should be written once and never edited again. Any editing should be done at
    the ini file level.

  3. #3
    Guest

    Re: Open file in Read and write mode

    In the windows/NT world ,I'd write a generic routine like:

    [-] CreateBatchFile(STRING sFilePath, STRING sCompany, STRING sSQLPath)
    [ ] STRING sTemp = ""
    [ ]
    [-] if SYS_FileExists("{sFilePath}\MyBatch_old.bat")
    [ ] SYS_RemoveFile ("{sFilePath}\MyBatch_old.bat")
    [ ]
    [-] if SYS_FileExists("{sFilePath}\MyBatch.bat")
    [ ] SYS_MoveFile ("{sFilePath}\MyBatch.bat","{sFilePath}\MyBatch_ol d.bat")
    [ ]
    [ ] HFILE hOutFile= FileOpen ("{sFilePath}\MyBatch.bat", FM_WRITE)
    [ ] HFILE hInFile = FileOpen("{sFilePath}\MyBatch_old.bat", FM_READ)
    [ ] //read whatever from MyBatch_old.bat
    [ ] // or prep the file yourself using the following
    [ ] sTemp = "c:\{sCompany}\install\bin\jview -cp "c:\{sCompany}\install\lib\custom.zip;" test.Load -D default -v c:\{sSQLPath}"
    [ ]
    [ ] FileWriteLine (hOutFile, "sTemp")
    [ ]
    [ ] FileClose (hInFile)
    [ ] FileClose (hOutFile)

    Or, use the Ini file as previously suggested in combination with a routine that builds your batch file. I used something very similar to prepare ftp scripts which contained a new script telling the ftp user what files to ftp

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 05:38 PM.

Copyright BetaSoft Inc.