Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: FINDSTR help

  1. #1
    New to the CF scene
    Join Date
    Jan 2019
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    FINDSTR help

    Hello,

    I'm having trouble with FINDSTR and was hoping someone where might be able to help me. I'm using a curl command that is returning a very ugly and large XML, which I'm sending to an output file (called output.txt). I then want to use FINDSTR to look for a MAC address that is embedded somewhere within the XML and then have it set to an environment variable for the LOCAL_USER to be able to access later.

    I'm having an issue with the FINDSTR command and it's output.

    My first attempt after reading through the man for FINDSTR was this:
    Code:
    FINDSTR /r /B[a-z0-9]{2}:[a-z0-9]{2}:[a-z0-9]{2}:[a-z0-9]{2}:[a-z0-9]{2}:[a-z0-9]{2}/E c:\Users\<myUsername>\Desktop\sandbox\output.txt
    However, FINDSTR spews out this and then hangs forever:

    Code:
    FINDSTR: /[ ignored
    FINDSTR: /a ignored
    FINDSTR: /- ignored
    FINDSTR: /z ignored
    FINDSTR: /0 ignored
    FINDSTR: /- ignored
    FINDSTR: /9 ignored
    FINDSTR: /] ignored
    FINDSTR: /{ ignored
    FINDSTR: /2 ignored
    FINDSTR: /} ignored
    So then I tried using the begin string & end string tokens for regular expression, but received no output.

    Code:
    FINDSTR /r ^[a-z0-9]{2}:[a-z0-9]{2}:[a-z0-9]{2}:[a-z0-9]{2}:[a-z0-9]{2}:[a-z0-9]{2}$ c:\Users\<MyUsername>\Desktop\sandbox\output.txt
    Any help would be appreciated. Thanks

    Also, here's a snippet of the XML file that contains the MAC address I'm looking for.

    Code:
    <CameraStatusModel xmlns="***URL contains sensitive info, so removing it***">
      <CameraStatusModel.ActiveCamera>
        <RectilinearCameraDeviceModel CompassHeading="0" IsConfigured="False" MACAddress="00:30:53:27:27:f4" Make="Basler" Name="">
          <RectilinearCameraDeviceModel.CalibrationMask>
            <RectilinearCalibrationMaskModel Id="a1155f60-2900-442c-82a8-6c00dadbf243" Length="0" Width="0" />

  2. #2
    New to the CF scene
    Join Date
    Jan 2019
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Did I post this in the correct forum?

  3. #3
    New Coder
    Join Date
    Jan 2013
    Location
    Canada
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this instead:
    Code:
    [a-z0-9][a-z0-9]:[a-z0-9][a-z0-9]:[a-z0-9][a-z0-9]:[a-z0-9][a-z0-9]:[a-z0-9][a-z0-9]:[a-z0-9][a-z0-9]
    I don't think batch findstr regex is as fancy considering the limitations of some characters too in batch.
    Microsoft MVP .NET Programming - (2012 - 2017)
    ®Crestron DMC-T Certified Automation Programmer & Software Developer

  4. #4
    Senior Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Location
    Keene, NH
    Posts
    3,427
    Thanks
    4
    Thanked 488 Times in 476 Posts
    Quote Originally Posted by Quaternions View Post
    Did I post this in the correct forum?
    Yes, but good luck finding anyone trying to do this type of processing from a Windows command line.
    “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies.” – C.A.R. Hoare, The 1980 ACM Turing Award Lecture
    http://www.cutcodedown.com


 

Tags for this Thread

Posting Permissions

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