Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Interacting with a console utility

Interacting with a console utility

Scheduled Pinned Locked Moved C#
toolsquestion
5 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hhrafn
    wrote on last edited by
    #1

    I have a console utility I'd like to interact with and get it's output. I can send in a list of commands into it via < like this: myapp < commmands.txt also I can do: myapp "command1 asdf" "command2 asdf" "command3 asdf 223" and so on.. What feature would I use to send commands into it and what would I use to read it's output ? thanks, H

    C 1 Reply Last reply
    0
    • H hhrafn

      I have a console utility I'd like to interact with and get it's output. I can send in a list of commands into it via < like this: myapp < commmands.txt also I can do: myapp "command1 asdf" "command2 asdf" "command3 asdf 223" and so on.. What feature would I use to send commands into it and what would I use to read it's output ? thanks, H

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      hhrafn wrote: What feature would I use to send commands into it and what would I use to read it's output ? Console.Read() and Console.ReadLine() to read in commands. What do you mean by "read it's output"? What is going to read what output?


      My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

      H 1 Reply Last reply
      0
      • C Colin Angus Mackay

        hhrafn wrote: What feature would I use to send commands into it and what would I use to read it's output ? Console.Read() and Console.ReadLine() to read in commands. What do you mean by "read it's output"? What is going to read what output?


        My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

        H Offline
        H Offline
        hhrafn
        wrote on last edited by
        #3

        Let's say I'm interacting with the utility "dir" i'd like to do as my command: "dir " + strMyDir and then read the output from this command and parse it to my likeing :)

        C 1 Reply Last reply
        0
        • H hhrafn

          Let's say I'm interacting with the utility "dir" i'd like to do as my command: "dir " + strMyDir and then read the output from this command and parse it to my likeing :)

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          You can use the Process[^] class to launch commands and read their output. Also, I'm assuming that dir is just an example because you know that you can use the FileInfo and DirectoryInfo classes much more effectively than parsing text from the dir command.


          My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

          H 1 Reply Last reply
          0
          • C Colin Angus Mackay

            You can use the Process[^] class to launch commands and read their output. Also, I'm assuming that dir is just an example because you know that you can use the FileInfo and DirectoryInfo classes much more effectively than parsing text from the dir command.


            My: Blog | Photos WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

            H Offline
            H Offline
            hhrafn
            wrote on last edited by
            #5

            Yes, thanks. :-D

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups