Created
August 27, 2024 12:32
-
-
Save NiceRath/50e2ae549f4789c95d10c23ada20948d to your computer and use it in GitHub Desktop.
Python3 - Write to OS pipe /dev/fd/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# this can be useful in CI environments if you need to process config or secrets and pipe them to the parent process in a secure manner | |
import io | |
import os | |
from time import sleep | |
w = io.open(69, 'wb', 0) | |
w.write(b'MY SECRE3T') | |
w.flush() | |
# print(os.listdir('/dev/fd/')) | |
# parent process can read the output like this: | |
# python3 test.py 69> test.txt | |
# or redirect it to default stdout | |
# python3 test.py 69>&1 1>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment