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.

5
  • 2
    That looks like a PowerShell error message, not a "normal" command-prompt ("DOS prompt") error message. Commented Nov 25, 2019 at 14:56
  • The file redirection symbol is '>'. Try change in it. Commented Nov 25, 2019 at 14:59
  • @DiegoBascans That re-directs output to a file. Anyway, this is a dupe. Commented Nov 25, 2019 at 15:02
  • 1
    @DiegoBascans < is commonly used for input redirection, to redirect standard input from a file. Except in PowerShell, apparently. Commented Nov 25, 2019 at 15:02
  • 1
    Also, this one: stackoverflow.com/questions/11447598/… Commented Nov 25, 2019 at 15:05

1 Answer 1

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).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.