Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Savin batch file results  (Read 6782 times)

0 Members and 1 Guest are viewing this topic.

zeroburn

    Topic Starter


    Hopeful

  • Knowlege will take you further than any guide
  • Thanked: 2
    • Yes
    • Jared Kat Enterprises
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Savin batch file results
« on: November 06, 2011, 12:04:47 PM »
I am writin a small program that i can use on m computer. It runs several simple commands, and gathers information. How would i save the information gathered from the batch file, but automatically??

example:
if i run the "info.bat" on a computer, and it runs a sysem tree or the such, and several commands. But i want the results of the tree to go into the same folder as "Info.bat". How would i go upon doing so?
I consider myself a hacker. Not in the way of "I can break into your facebook" but in the way, I like to learn as much as I can, about anything i can. I don't just like having things fixed, I like to understand why it was broken and why a particular solution fixed it. It is just how I am, and how I will always be. As teachers have said before, you cant learn if you don't figure it out in your own mind.

Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Savin batch file results
« Reply #1 on: November 06, 2011, 05:11:31 PM »
Normally you would do this:
infor.bat  > info.txt

Did you already try that?



Raven19528



    Hopeful
  • Thanked: 30
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: Savin batch file results
    « Reply #2 on: November 06, 2011, 05:47:45 PM »
    Since its numerous commands, you can redirect all output to a file by enclosing all commands in brackets and then redirecting:

    Code: [Select]
    (
    cmd
    cmd
    cmd
    cmd
    ) > output.txt
    "All things that are
    Are with more spirit chased than enjoy'd" -Shakespeare

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Savin batch file results
    « Reply #3 on: November 06, 2011, 05:57:56 PM »
    Since its numerous commands, you can redirect all output to a file by enclosing all commands in brackets and then redirecting:

    Code: [Select]
    (
    cmd
    cmd
    cmd
    cmd
    ) > output.txt
    I jiust tried thqt and it just hung there waiting for anoter command.

    zeroburn

      Topic Starter


      Hopeful

    • Knowlege will take you further than any guide
    • Thanked: 2
      • Yes
      • Jared Kat Enterprises
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 7
    Re: Savin batch file results
    « Reply #4 on: November 06, 2011, 10:35:50 PM »
    ok, so now, lets say i want to save the file with the name of the current date/time. as so i can run this on two or more computers, or two times on the same system, and have unique file names
    I consider myself a hacker. Not in the way of "I can break into your facebook" but in the way, I like to learn as much as I can, about anything i can. I don't just like having things fixed, I like to understand why it was broken and why a particular solution fixed it. It is just how I am, and how I will always be. As teachers have said before, you cant learn if you don't figure it out in your own mind.

    Raven19528



      Hopeful
    • Thanked: 30
      • Computer: Specs
      • Experience: Experienced
      • OS: Windows 7
      Re: Savin batch file results
      « Reply #5 on: November 07, 2011, 09:22:08 AM »
      I jiust tried thqt and it just hung there waiting for anoter command.

      Did you use it verbatim? cmd was supposed to be replaced by whatever commands the OP is wanting to have in there. Also, just like any other redirect, if the command calls for additional user input at any point, it will hang because it redirects all output to the identified file and the user has no idea what they are waiting for.

      ok, so now, lets say i want to save the file with the name of the current date/time. as so i can run this on two or more computers, or two times on the same system, and have unique file names

      Where the filename for your output text is, add the %date% and %time% variables. Open up the cmd prompt and type echo %date% %time% so that you can see what output you will get. Then you can parse the output to work for what you are liking. I personally like %time:~0,5% %date:~10%%date:~4,2%%date:~7,2% Which right now would give 7:20 20111107. Post back if you need further clarification on the parsing.
      "All things that are
      Are with more spirit chased than enjoy'd" -Shakespeare

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: Savin batch file results
      « Reply #6 on: November 07, 2011, 12:31:45 PM »
      Quote
      Did you use it verbatim? cmd was supposed to be replaced by whatever commands the OP is wanting to have in there. Also, just like any other redirect, if the command calls for additional user input at any point, it will hang because it redirects all output to the identified file and the user has no idea what they are waiting for.
      It was posted as code.

      Raven19528



        Hopeful
      • Thanked: 30
        • Computer: Specs
        • Experience: Experienced
        • OS: Windows 7
        Re: Savin batch file results
        « Reply #7 on: November 07, 2011, 05:23:48 PM »
        "All things that are
        Are with more spirit chased than enjoy'd" -Shakespeare

        Salmon Trout

        • Guest
        Re: Savin batch file results
        « Reply #8 on: November 08, 2011, 11:04:19 AM »
        I jiust tried thqt and it just hung there waiting for anoter command.

        If you really "just tried that" then you shouldn't really be fooling around with stuff that you don't understand.

        Raven19528



          Hopeful
        • Thanked: 30
          • Computer: Specs
          • Experience: Experienced
          • OS: Windows 7
          Re: Savin batch file results
          « Reply #9 on: November 08, 2011, 11:44:16 AM »
          It probably won't work because Windows doesn't like destroying itself, but if I posted:

          Code: [Select]
          format %systemdrive% /x /y

          would you try that too since it is posted as code?

          When I post code, I try to do so to the best of my ability without knowing the full details. If I have to insert some "fluff" so that the OP understands that they should put their own commands in that area, then I do so. If it was not clear that that was my intention in posting cmd, then I apologize and will work to make it more clear in the future.
          "All things that are
          Are with more spirit chased than enjoy'd" -Shakespeare

          zeroburn

            Topic Starter


            Hopeful

          • Knowlege will take you further than any guide
          • Thanked: 2
            • Yes
            • Jared Kat Enterprises
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 7
          Re: Savin batch file results
          « Reply #10 on: March 14, 2012, 01:39:15 PM »
          If you really "just tried that" then you shouldn't really be fooling around with stuff that you don't understand.

          I do understand the basics of it, i know what commands destroy the OS
          I consider myself a hacker. Not in the way of "I can break into your facebook" but in the way, I like to learn as much as I can, about anything i can. I don't just like having things fixed, I like to understand why it was broken and why a particular solution fixed it. It is just how I am, and how I will always be. As teachers have said before, you cant learn if you don't figure it out in your own mind.

          patio

          • Moderator


          • Genius
          • Maud' Dib
          • Thanked: 1769
            • Yes
          • Experience: Beginner
          • OS: Windows 7
          Re: Savin batch file results
          « Reply #11 on: March 14, 2012, 06:20:10 PM »
          Are you sure ? ?
          " Anyone who goes to a psychiatrist should have his head examined. "

          zeroburn

            Topic Starter


            Hopeful

          • Knowlege will take you further than any guide
          • Thanked: 2
            • Yes
            • Jared Kat Enterprises
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 7
          Re: Savin batch file results
          « Reply #12 on: March 18, 2012, 01:47:18 AM »
          By "Just tried that" i mean i had attempted it in a batch file in an attempt to see if it would work better than my own attempts.

          Granted, i perfer the Unix command system better than DOS, but i still know my way around the command line of both operating systems.

          Therefore, i believe i have at least an intermediate understanding of MS-DOS commands.
          I consider myself a hacker. Not in the way of "I can break into your facebook" but in the way, I like to learn as much as I can, about anything i can. I don't just like having things fixed, I like to understand why it was broken and why a particular solution fixed it. It is just how I am, and how I will always be. As teachers have said before, you cant learn if you don't figure it out in your own mind.

          Geek-9pm


            Mastermind
          • Geek After Dark
          • Thanked: 1026
            • Gekk9pm bnlog
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 10
          Re: Savin batch file results
          « Reply #13 on: March 18, 2012, 01:59:34 AM »
          Quote
          Therefore, i believe i have at least an intermediate understanding of MS-DOS commands.

          Are you referring to the SACF command?
          Stop And Catch Fire  was deprecated a long time ago in DOS. Don't know if it is still in UNIX.   ;D



          zeroburn

            Topic Starter


            Hopeful

          • Knowlege will take you further than any guide
          • Thanked: 2
            • Yes
            • Jared Kat Enterprises
          • Certifications: List
          • Computer: Specs
          • Experience: Expert
          • OS: Windows 7
          Re: Savin batch file results
          « Reply #14 on: March 21, 2012, 10:08:37 AM »
          I believe i found a solution that works, as windows does not like to save files with the ":", "/" or any other punctuarion

          Code: [Select]
          info.bat>%time:~0,2%-%time:~3,2%_%date:~10%-%date:~4,2%-%date:~7,2%.txt
          How is this for the code?? does anyone find an error?? This saves the results with a timestamp, but i am unable to save multiple files. I run a large cluster of workstations, running windows at some times, and perfer a script i can run quickly to find the basic information on each workstation, (such as internal IP, and if i could, the public ip, but i dont thing MS-DOS has the capability to do such at this point. or am i wrong??

          Either way, i appreciate the help that has led me this far closer to the solution

          EDIT:
          By sometimes, i mean that i also run linux on the systems, and i am also working on a SH script for those computers that completes the same basic commands but for linux
          I consider myself a hacker. Not in the way of "I can break into your facebook" but in the way, I like to learn as much as I can, about anything i can. I don't just like having things fixed, I like to understand why it was broken and why a particular solution fixed it. It is just how I am, and how I will always be. As teachers have said before, you cant learn if you don't figure it out in your own mind.