I've a bash script invoking a python script I want to feed the content of file
via stdin. Calling the bash script like:
./script.sh < file
And the contents of script.sh
:
#! /usr/bin/env bash
pushd /some/python/virtual/environment/working/dir
source venv/bin/activate
python main.py ??????
deactivate
popd
I've no idea what to fill in for ??????
to pass the contents of file
given to the bash script as stdin to the python script main.py
.
Note that file
can be a substantial text file and using bash's read
is not desirable.
Using stdin when invoking the bash script is a requirement. I'm flexible to pass whatever to main.py
.
Any ideas out there how to tackle this conundrum?
addition
The answer by @cas made it clear to me that I also need to explain in which context I try to use script.sh
.
I want to use script.sh
as a forwarding script in ~/.forward
, with the contents:
|/path/to/script.sh
Which postfix does call as /path/to/script.sh
; the log is clear about that. A simple test using a dressed down version of the python script, like:
|/path/to/simple/main.py
Demonstrates that postfix does call main.py
with the content of the mail on the stdin. But the combination doesn't seem to work.
local
LDA or something else, likeprocmail
ordeliver
? is there anything in your~/.bashrc
which might disturb the environment as seen bymain.py
when run from withinscript.sh
? maybe log the environment by running something like{ typeset -p ; echo } >> "/tmp/forward.log"
inside script.sh. – cas Sep 11 at 9:50