Results 1 to 6 of 6

Thread: DOS help, I guess.

  1. #1

    Default DOS help, I guess.

    I have a program I want to run and automatically enter an input for. How do I do that from the command line?

    I have a program called 80initparse.exe that needs to take an input string (contained in a variable). So I do 80initparse.exe to run the program. But how do I get it to take that extra input?

  2. #2
    Got obliterated Recognized Member Shoeberto's Avatar
    Join Date
    Jun 2000
    Location
    THE OC BABY
    Posts
    12,018
    Blog Entries
    1
    Contributions
    • Former Cid's Knight

    Default

    Are you programming something? If it's in C++, then you'd want something like this:

    Code:
    #include <iostream>
    using namespace std;
    int main() {
    string myinput;
    cout << "Input: ";
    cin >> myinput;
    return 0;
    }
    I'm not exactly sure what you're asking. If it's how to run a program from the command prompt, you just change to the directory it's in using cd [directory name] and then type in the name of your program.


  3. #3
    Ominous Wanderer Tech Admin Samuraid's Avatar
    Join Date
    Oct 2001
    Posts
    5,522

    Default

    If you want to pass switches directly in, like: (I apologize if this is totally redundant and you already know this)
    Code:
    80initparse.exe switch1 switch2
    ...just grab the arguments off main().
    Code:
    int main(int argc, char **argv)
    argc contains the number of arguments passed into the program from the command line.
    argv is an array containing the arguments placed in the command line.
    Note: argv[0] contains the name of the program (in this case 80initparse.exe) and the arguments start at argv[1]

  4. #4

    Default

    Depending on your DOS shell, if it supports the pipe (|), use that : ).

  5. #5

    Default

    Quote Originally Posted by Samuraid
    If you want to pass switches directly in, like: (I apologize if this is totally redundant and you already know this)
    Code:
    80initparse.exe switch1 switch2
    ...just grab the arguments off main().
    Code:
    int main(int argc, char **argv)
    argc contains the number of arguments passed into the program from the command line.
    argv is an array containing the arguments placed in the command line.
    Note: argv[0] contains the name of the program (in this case 80initparse.exe) and the arguments start at argv[1]
    You have no idea how helpful that was. Thanks a bunch!

    For lurkers, instead of using "char **argv", I used "char *argv[]", with no difference.

  6. #6
    Ominous Wanderer Tech Admin Samuraid's Avatar
    Join Date
    Oct 2001
    Posts
    5,522

    Default

    Ya, either one should work. I just couldn't remember the exact syntax at the moment so I just copied and pasted that line from some C++ I had written a while ago.

Posting Permissions

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