How to run python tool Command includes cat and pipeline on Linux Server from dot net console App (C#)?

NALB 61 Reputation points


I have asked on your platform earlier question of how to run python command tool from Visual Studio and you provided me with the below code

// start process
using var process = Process.Start(new ProcessStartInfo
    UseShellExecute = false
    FileName = "amass",
    RedirectStandardOutput = true,
    ArgumentList = { "enum", "-d", "" }
// read std out
var output = process.StandardOutput.ReadToEnd();  
// wait for exit
// write out out
File.WriteAllText("~/FolderXTest/file.txt", output);

how ever trying to run command that include cat and pipelines not wotking .. I have tried executing the below code

My command line is (cat fileName.txt | toolName > text.txt)

i recived errors while executing the above code such as :

cat: '|': No such file or directory

cat: ToolName: No such file or directory

Can you please provide me with the right code and example of it ?

Thank you

A set of technologies in the .NET Framework for building web applications and XML web services.
4,234 questions
0 comments No comments
{count} votes

Accepted answer
  1. Bruce ( 57,731 Reputation points

    the pipe (|) and redirect (>) are shell command tokens (bash, etc). you can either create a shell script and execute or implement in you program.

    you implement pipe, by forking, redirect stdout to stdin, and then exec the new program. Windows does not really have this model, so process doesnt really have it. you will need to use streams

    process start cat redirecting output to a stream

    process start toolName redirect input to the the stream. from above.

    write the output of toolName output to the desired text file.

    note: while Ive written my own unix shell programs in the past, I used c. here is a simple explanation of how shells work:

1 additional answer

Sort by: Most helpful
  1. Bruce ( 57,731 Reputation points

    (extra post to display)

    0 comments No comments