Jump to content

batch file to enter a number

- - - - -

  • Please log in to reply
10 replies to this topic

#1
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
Hello,
I want to make batch which run program 10 times and after that enter a number in that program.
Is it possible that we do it?

#2
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
Can't say whether it's possible until we get some more details of what you're trying to do.

How are you trying to enter a number into your program? Is it passed in as a command line argument? If so, that's easy to do in a command line script. If the program doesn't accept command line arguments, but rather requires its input to be entered into a GUI, well, that's gonna be a bit more of a problem.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#3
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
I have exe file which get 3 strings and after that make one output file. I don't have source file of that program but I need to run this program for 1000 times with different strings.
Now how can I enter these string. (No argument I test it no answer)

#4
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
Again, how is the application getting these string inputs? Is it by command line arguments or by some other means? Also, what is the application's behavior in regards to the output file? Can you specify the name of the file to output to, or is the filename hard-coded in the software? If the filename is hard coded, does it overwrite the file or append to it each time it runs?
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#5
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
My program that I want to run is something like bellow program in C++:
#include <iostream>
using namespace std;
int main()
{
    char a[30],b[30],c[30];
    cin >> a;
    cin >> b;
    cin >> c;
    cout << c;
    return 0;
}
I don't have source code and just I can enter input in console (It is console application)

#6
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
Then that should be as simple as writing the same commands that you ordinarily type to run the program into a command line script and executing the script. Depending on where your word list is coming from, you could use the looping constructs of your command line shell to make this even easier.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#7
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
I know loops and ... but how can I do input string?
I use CALL for opening program but for input I don't know anythings

#8
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
I don't know which command line shell you're using, so I couldn't tell you what you should do, but all shells have some form of mechanism for data input. In bash for example, you can refer to the command line arguments by using $0, $1, $2, etc. ($0 is the script name, and probably not of much use to you. The first argument begins with $1.) I believe in the Windows command shell, it is %1, %2, etc. With those, you can make your script accept command line arguments when you execute it just like a program would.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#9
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
program file is hamed.exe
I use :
CALL hamed.exe
It open hamed and wait for input file (I don't know how can I enter that string)

#10
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
Either type your arguments after the executable name in your script file as you would on the command line, or use variables to stand in their place if looping through a list, for instance.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#11
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
I test what you say.
but it doesn't help me.
I upload a simple program which get and int number and print it.
please make batch for it.

Attached Files






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users