0

I am trying to write a program where I have to use file redirection to cin text from another text file. I'm seeing that I should be able to use .\a.exe < inputFile.txt, but for whatever reason my windows terminal does not recognize "<". This is the error I got :

At line:1 char:14
+ .\a.exe 1000 <input1L.txt
+              ~
The '<' operator is reserved for future use.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RedirectionNotSupported

I don't know why it's not recognizing it and I don't know how to fix it.

273K
  • 29,503
  • 10
  • 41
  • 64
laurant
  • 11
  • 1

1 Answers1

2

As the error message says, the < operator isn't implemented, but in practice you can work around this by piping (|) instead.

In your example, instead of this:

.\a.exe 1000 <input1L.txt

You should be able to write this:

Get-Content input1L.txt | .\a.exe 1000

(presuming your .\a.exe accepts standard input).

Bill_Stewart
  • 22,916
  • 4
  • 51
  • 62