Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23276

Export `stdout` and `stderr` of a single-line bash command to text file while using python module followed by `-m` syntax

$
0
0

I would like to export the stdout and stderr of a bash command to the same text file.

The bash command is a single-line command that calls python3 followed by the name of the module and function, followed by three arguments (each using --).

The bash command is running on an HPC as part of a slurm job.

python3 -m module.function --Arg1 Val1 --Arg2 Val2 --Arg3 Val3 

I tried the following but it failed. It assumes that 2> or > are extra information to the last argument.

python3 -m module.function --Arg1 Val1 --Arg2 Val2 --Arg3 Val3 2> Output.txtpython3 -m module.function --Arg1 Val1 --Arg2 Val2 --Arg3 Val3 > Output.txt

How to be able to export the output to a file without making large changes to the syntax (I need to keep using a single line command for calling the function from the module).

Thanks


Viewing all articles
Browse latest Browse all 23276

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>