Input variables from Text file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rpawliko
    Visitor
    • Nov 2014
    • 8

    Input variables from Text file

    I'd like to be able to set up a script that would read input from a text file. The objective would be to hand off the text file to an operator who would then run a BC script that would read in the variables from the text file.

    Example:

    %1, %2, %3 would be in a snapshot_io.txt file, as below:
    LogFile~C:\Snaplogs\snapshotlogs.txt
    Source~S:\Dir\we\want\to\snapshot
    Output~d:\BCSnaps\MondaySnapshot

    Snapshot script
    #Get Variables from snapshot_io.txt
    ????
    #Log output
    log verbose append:"%1"
    #
    #Capture directory contents to snapshot file
    snapshot save-crc save-version no-filters expand-archives path:"%2" output:"%3"

    Is this doable given the scripting capabilities of BC?
  • Aaron
    Team Scooter
    • Oct 2007
    • 15997

    #2
    BC Scripting would not support a .txt file with multiple inputs. You would need an alternate script (Batch file, VBScript, etc) to pull this information out and call a BC command line with the %1, %2 variables. BC Scripting does support variables when passed on the command line:

    bcompare.exe "@c:\bcscript.txt" "variabletextA" "variabletextB" "variabletextC"

    which can then be referenced in the bc script with %1, %2, %3, etc
    Aaron P Scooter Software

    Comment

    • rpawliko
      Visitor
      • Nov 2014
      • 8

      #3
      Example?

      Can you provide an example of how this would look in a batch file?

      Originally posted by Aaron
      BC Scripting would not support a .txt file with multiple inputs. You would need an alternate script (Batch file, VBScript, etc) to pull this information out and call a BC command line with the %1, %2 variables. BC Scripting does support variables when passed on the command line:

      bcompare.exe "@c:\bcscript.txt" "variabletextA" "variabletextB" "variabletextC"

      which can then be referenced in the bc script with %1, %2, %3, etc

      Comment

      • Aaron
        Team Scooter
        • Oct 2007
        • 15997

        #4
        I'm not familiar with the input pattern or how to parse it, but once you had the text in bat variables, it would call the program with:
        set var1=c:\folder1
        "c:\program files (x86)\beyond comapre 4\bcompare.exe" "@c:\bcscript.txt" "%var1%" "%var2%" "%var3%"

        where var1,2, and 3 have the text values of the parameter, such as a file path: c:\folder1\

        The path is then passed into Beyond Compare, which can then be referenced in the script. Quotes are important to help capture whitespace as part of a path.
        Aaron P Scooter Software

        Comment

        Working...