Python equivalent to perl -pe?

Yes, you can use Python from the command line. python -c <stuff> will run <stuff> as Python code. Example: python -c “import sys; print sys.path” There isn’t a direct equivalent to the -p option for Perl (the automatic input/output line-by-line processing), but that’s mostly because Python doesn’t use the same concept of $_ and whatnot … Read more

Piping Text To An External Program Appends A Trailing Newline

tl;dr: When PowerShell pipes a string to an external program: It encodes it using the character encoding stored in the $OutputEncoding preference variable It invariably appends a trailing (platform-appropriate) newline. Therefore, the key is to avoid PowerShell’s pipeline in favor of the native shell’s, so as to prevent implicit addition of a trailing newline: If … Read more

How can I read a child process’s output?

There are a few bugs in your code, but the most important is that you’ve specified FALSE for the bInheritHandles argument to CreateProcess. The new process can’t use the pipe if it doesn’t inherit the handle to it. In order for a handle to be inherited, the bInheritHandles argument must be TRUE and the handle … Read more

Go exec.Command() – run command which contains pipe

Passing everything to bash works, but here’s a more idiomatic way of doing it. package main import ( “fmt” “os/exec” ) func main() { grep := exec.Command(“grep”, “redis”) ps := exec.Command(“ps”, “cax”) // Get ps’s stdout and attach it to grep’s stdin. pipe, _ := ps.StdoutPipe() defer pipe.Close() grep.Stdin = pipe // Run ps first. … Read more

git stderr output can’t pipe

I think that at least some of progress reports gets silenced when output is not a terminal (tty). I’m not sure if it applies to your case, but try to pass –progress option to ‘git clone’ (i.e. use git clone –progress <repository>). Though I don’t know if it is what you wanted to have.

Command Line Pipe Input in Java

By executing “java Read < input.txt” you’ve told the operating system that for this process, the piped file is standard in. You can’t then switch back to the command line from inside the application. If you want to do that, then pass input.txt as a file name parameter to the application, open/read/close the file yourself … Read more