Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#!/usr/bin/env python3 """ [deadeye@nexus ~]$ python3 out.py \ <(echo "Hello World") \ <(echo "Enter the Matrix") \ <(echo "Oh, it's an countdown starting at 63") \ <(echo "Another argument") Printing content from 1. argument: /dev/fd/63 Hello World Printing content from 2. argument: /dev/fd/62 Enter the Matrix Printing content from 3. argument: /dev/fd/61 Oh, it's an countdown starting at 63 Printing content from 4. argument: /dev/fd/60 Another argument """ import sys arguments = sys.argv[1:] message = rf""" python3 {sys.argv[0]} \ <(echo "Hello World") \ <(echo "Enter the Matrix") \ <(echo "Oh, it's an countdown starting at 63") \ <(echo "Another argument") """.lstrip() if not arguments: raise SystemExit(message) for number, file in enumerate(sys.argv[1:], start=1): print(f"Printing content from {number}. argument: {file}") if not file.startswith("/dev/fd/"): print(f"Argument {number} is not a PIPE: {file}") continue with open(file) as fd: try: while chunk := fd.read(1024): print(chunk, end="") except UnicodeDecodeError: print( f"Could not decode file '{file}' from argument {number}. UTF8 encoding is expected. Don't cat binary files" ) break print()
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)