Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Aug 2014
    Posts
    123
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Monitoring variable(s)

    Trying to watch 1-n variables for value changes from a batch script.
    With bash I could use a trap but cannot find anything about traps in DOS batch scripts. Is there none?
    The code monitors other batch scripts and the variables could be defined before use but would prefer if I can just monitor sort of on-the-fly changes to variables.
    Found an environmental variable %CMDLINE% which is somehow associated with input lines but CMDLINE/? said it knows nothing about it.
    Is that possibly what I need but am addressing it incorrectly? OR is there an env var which watches variables?
    Last edited by spark55; 2014-11-08 at 06:41.

  2. #2
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,421
    Thanks
    33
    Thanked 195 Times in 175 Posts
    I know of no way to do in a BATch file what you appear to want...
    BATcher

    Time prevents everything happening all at once...

  3. #3
    2 Star Lounger
    Join Date
    Aug 2014
    Posts
    123
    Thanks
    19
    Thanked 0 Times in 0 Posts
    Think I have found a method:
    In a loop:
    Read a line from the .bat file
    Scan the line for known variables
    If found write echo line containing BP## variable= %varname%
    followed by a pause command
    then write the line scanned to the same temp file.
    Convert the result to bat and run it.
    It ain't elegant but it should display variable values and may help to trace operations.
    Last edited by spark55; 2014-11-09 at 02:58.

  4. #4
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,199
    Thanks
    48
    Thanked 987 Times in 917 Posts
    If you can give us an example of the file you are running and where you want to monitor the variables we may be able to help.

    cheers, Paul

Posting Permissions

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