_curses.error: cbreak() returned ERR when running jenkins

I’m running pg_activity through a bash script to simulate that pg_activity that can launch correctly without any issues.
Below is my script


/soft/python3.7/bin/pg_activity <<EOF > /tmp/another_log_file141123.log 2>&1

The aim of my bash script is to emulate the run of pg_activity, then input a h plus q twice as a user input.

Through a terminal, it behaves correctly. Issue is I’m sending it through a Jenkins pipeline.

it gives me the following errors

Traceback (most recent call last):
  File "/soft/python3.7/bin/pg_activity", line 320, in main
  File "/soft/python3.7/lib/python3.7/site-packages/pgactivity/UI.py", line 472, in init_curses
  File "/soft/python3.7/lib/python3.7/site-packages/pgactivity/UI.py", line 609, in __init_curses
_curses.error: cbreak() returned ERR

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/soft/python3.7/bin/pg_activity", line 462, in <module>
  File "/soft/python3.7/bin/pg_activity", line 401, in main
  File "/soft/python3.7/lib/python3.7/site-packages/pgactivity/UI.py", line 696, in at_exit_curses
_curses.error: nocbreak() returned ERR

I have checked the available ressources on the net and there is nothing really striking to solve my problem.

Any clues or hints would be welcomed.

Perhaps curses opens “/dev/tty” to access the terminal when standard I/O has been redirected.

If pg_activity requires a terminal, then maybe you can use tmux to give it a pseudoterminal.

1 Like

You could also try a newer version of pg_activity, as 2.0.0 apparently switched from curses to blessed.Terminal, which might handle the situation differently.

1 Like

Thank you @kon for both answers.