1

I had compiled a cpp (c++) file, which generated an executable (a.exe file) in Windows.
In Linux, a.out file would be generated.
I want to run the executable but I do not want to manually enter the inputs that the executable needs.
Hence, I aim to feed the inputs from a saved file to the executable.

For example, the bash equivalent would be

$ ./a.out < testfile

In Windows (Windows Powershell / pwsh), I want to run my a.exe instead of a.out.
The testfile here contains some text data to feed to the executable (which is not important), for example:

3
123
1234
12344

I just want to feed the executable, some input from an existing file.
How do I do it?

  • 2
    Read following : https://stackoverflow.com/questions/11447598/redirecting-standard-input-output-in-windows-powershell?force_isolation=true – jdweng May 22 '23 at 16:00
  • 1
    In short: PowerShell has _no_ `<` operator for providing data from a file to a program via stdin and instead requires the use of `Get-Content` in a pipeline. That is, instead of `someProgram – mklement0 May 22 '23 at 17:53

0 Answers0