The '<' operator is reserved for future use

PowershellRedirectIo Redirection

Powershell Problem Overview


I am using PowerShell and am trying to run the following command:

.\test_cfdp.exe < test.full | tee test.log

test.full is a script that mimics command line inputs to test_cfdp.exe. However, I get the following error:

The '<' operator is reserved for future use.

Is there another way (i.e. cmdlet) I can use to get this command to work in PowerShell?

Powershell Solutions


Solution 1 - Powershell

This was not supported in PowerShell v1 [and as of v5, it's still not...]

An example workaround is:

Get-Content test.full | .\test_cfdp.exe | tee test.log

Solution 2 - Powershell

Also try:

cmd /c '.\test_cfdp.exe < test.full | tee test.log'

Solution 3 - Powershell

I have switched to linux shell and it works

Solution 4 - Powershell

If you want to run this command more times, you can just make a *.bat file with the original syntax. That's another solution.

Solution 5 - Powershell

In version 7 of PowerShell, you still need to use Get-Content to get the contents of an item in the specified location. For example, if you want to load a file into a Python script and write the result to a file. Use this construct:

PS > Get-Content input.txt | python .\skript.py > output.txt

Or with displayed and saved in a file:

PS > Get-Content input.txt | python .\skript.py | tee output.txt

Or switch to cmd to use the '<' operator:

C:\>python .\skript.py < input.txt > output.txt

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBlade3View Question on Stackoverflow
Solution 1 - PowershellRuben BartelinkView Answer on Stackoverflow
Solution 2 - PowershellearGrowthView Answer on Stackoverflow
Solution 3 - PowershellMiralView Answer on Stackoverflow
Solution 4 - PowershellseniorpreacherView Answer on Stackoverflow
Solution 5 - PowershellSzczerskiView Answer on Stackoverflow