Reputation: 14033
I would like to do something like this:
find -name "foo*" | python main.py
and access all the files that were found by the find program. How do I access that in Python?
Upvotes: 16
Views: 18559
Reputation: 153
I Like using $(...) for command-line arguments that are dependent on some other program. I think this would work for your program python main.py $(find -name "foo*")
. Found here
Upvotes: 4
Reputation: 301587
I think you can do:
import sys
print sys.stdin.readlines() #or what you want
Upvotes: 3
Reputation: 6339
Use sys.stdin.read() or raw_input()
A pipeline just changes the stdin file descriptor to point to the pipeline that the command on the left is writing to.
Upvotes: 4