3 added 21 characters in body
source | link

Assuming that your main.py script is correctly written to read from stdin and that nothing in venv/bin/activate reads from stdin(*), ?????? should be "nothing at all".

There are no previous commands in the bash script that will consume stdin before python, so python will just start consuming it.

#/bin/bash
pushd /some/python/virtual/environment/working/dir
source venv/bin/activate
python main.py
deactivate

Or make main.py executable and run it directly as ./main.py...works the same, either way.

(*) if there was, you probably wouldn't be able to do this at all, without something ugly like capturing all of stdin to a variable and then piping or <<< redirecting the variable into first venv/bin/activate and then main.py).


For a very obvious example of what is happening here and why this works, consider the following sh script kitten.sh:

#!/bin/sh
cat

It just runs cat, which begins reading from stdin and printing its input to stdout.

Assuming that your main.py script is correctly written to read from stdin and that nothing in venv/bin/activate reads from stdin(*), ?????? should be "nothing at all".

There are no previous commands in the bash script that will consume stdin before python, so python will just start consuming it.

#/bin/bash
pushd /some/python/virtual/environment/working/dir
source venv/bin/activate
python main.py
deactivate

Or make main.py executable and run it directly as ./main.py...works the same, either way.

(*) if there was, you probably wouldn't be able to do this at all, without something ugly like capturing all of stdin to a variable and then piping the variable into first venv/bin/activate and then main.py)


For a very obvious example of what is happening here and why this works, consider the following sh script kitten.sh:

#!/bin/sh
cat

It just runs cat, which begins reading from stdin and printing its input to stdout.

Assuming that your main.py script is correctly written to read from stdin and that nothing in venv/bin/activate reads from stdin(*), ?????? should be "nothing at all".

There are no previous commands in the bash script that will consume stdin before python, so python will just start consuming it.

#/bin/bash
pushd /some/python/virtual/environment/working/dir
source venv/bin/activate
python main.py
deactivate

Or make main.py executable and run it directly as ./main.py...works the same, either way.

(*) if there was, you probably wouldn't be able to do this at all, without something ugly like capturing all of stdin to a variable and then piping or <<< redirecting the variable into first venv/bin/activate and then main.py.


For a very obvious example of what is happening here and why this works, consider the following sh script kitten.sh:

#!/bin/sh
cat

It just runs cat, which begins reading from stdin and printing its input to stdout.

2 deleted 3 characters in body
source | link

Assuming that your main.py script is correctly written to read from stdin and that nothing in venv/bin/activate reads from stdin(*), ?????? should be "nothing at all".

There are no previous commands in the bash script that will consume stdin before python, so python will just start consuming it.

#/bin/bash
pushd /some/python/virtual/environment/working/dir
source venv/bin/activate
python main.py
deactivate

Or make main.py executable and run it directly as ./main.py...works the same, either way.

(*) if there was, you probably wouldn't be able to do this at all, not even with tee and process substitution because that would run inwithout something ugly like capturing all of stdin to a sub-shell....sovariable and then piping the variable into first venv/bin/activate couldn't affect the parent shell's environmentand then main.py)


For a very obvious example of what is happening here and why this works, consider the following sh script kitten.sh:

#!/bin/sh
cat

It just runs cat, which begins reading from stdin and printing its input to stdout.

Assuming that your main.py script is correctly written to read from stdin and that nothing in venv/bin/activate reads from stdin(*), ?????? should be "nothing at all".

There are no previous commands in the bash script that will consume stdin before python, so python will just start consuming it.

#/bin/bash
pushd /some/python/virtual/environment/working/dir
source venv/bin/activate
python main.py
deactivate

Or make main.py executable and run it directly as ./main.py...works the same, either way.

(*) if there was, you wouldn't be able to do this at all, not even with tee and process substitution because that would run in a sub-shell....so venv/bin/activate couldn't affect the parent shell's environment)


For a very obvious example of what is happening here and why this works, consider the following sh script kitten.sh:

#!/bin/sh
cat

It just runs cat, which begins reading from stdin and printing its input to stdout.

Assuming that your main.py script is correctly written to read from stdin and that nothing in venv/bin/activate reads from stdin(*), ?????? should be "nothing at all".

There are no previous commands in the bash script that will consume stdin before python, so python will just start consuming it.

#/bin/bash
pushd /some/python/virtual/environment/working/dir
source venv/bin/activate
python main.py
deactivate

Or make main.py executable and run it directly as ./main.py...works the same, either way.

(*) if there was, you probably wouldn't be able to do this at all, without something ugly like capturing all of stdin to a variable and then piping the variable into first venv/bin/activate and then main.py)


For a very obvious example of what is happening here and why this works, consider the following sh script kitten.sh:

#!/bin/sh
cat

It just runs cat, which begins reading from stdin and printing its input to stdout.

1
source | link

Assuming that your main.py script is correctly written to read from stdin and that nothing in venv/bin/activate reads from stdin(*), ?????? should be "nothing at all".

There are no previous commands in the bash script that will consume stdin before python, so python will just start consuming it.

#/bin/bash
pushd /some/python/virtual/environment/working/dir
source venv/bin/activate
python main.py
deactivate

Or make main.py executable and run it directly as ./main.py...works the same, either way.

(*) if there was, you wouldn't be able to do this at all, not even with tee and process substitution because that would run in a sub-shell....so venv/bin/activate couldn't affect the parent shell's environment)


For a very obvious example of what is happening here and why this works, consider the following sh script kitten.sh:

#!/bin/sh
cat

It just runs cat, which begins reading from stdin and printing its input to stdout.