I've got two Pis connected with ethernet cable (both Raspbian Bookworm). I've been using Pi A to control Pi B with SSH.

When I SSH into Pi B, I run a Python script. The results appear on Pi A (print commands, etc). I'm not sure how to see the results on Pi B, where the script is actually located. I don't know where I would see print commands, for example.

I ran a simple Pygame script (just a window with a black background), because I thought the GUI might open on Pi B. I couldn't see it.

Should I be using SSH at all for this, or is there a better way to do it?

2 Answers 2


On PiA run ssh PiB env. There is no TERM nor DISPLAY, prints on PiA. Next ssh PiB. Now on PiB, but still on physically on PiA, now run env. If there is a display run the Python script and is should display on PiB.

EDIT: My rpi2(RPi2) is your PiA and rpi0(RPi0) is your PiB

pi@RPi2:~ $ ssh [email protected] env | grep -E 'TERM|DISPLAY|USER'
pi@RPi2:~ $ ssh [email protected]
Linux RPi0 6.1.21+ #1642 Mon Apr  3 17:19:14 BST 2023 armv6l
Last login: Thu Jun 27 12:39:31 2024 from
pi@RPi0:~ $ env | grep -E 'TERM|DISPLAY|USER'
pi@RPi0:~ $ Python script (Should display on your PiB display)
  • I'm not sure I understand your instructions completely, because I couldn't get this to work. Here's what I typed into the terminal: ssh [email protected] env | ssh [email protected] | env | python pygame_test.py Commented Jun 27 at 13:45
  • When running a script across the network, the user's env is not filled out. When ssh to a user across the network, the user's env is filled out.
    – bstipe
    Commented Jun 27 at 18:03

How about simply using ssh to log in to PiB, then run the Python script on PiB? Redirect the output to a file on PiB and examine it when convenient.

pi@PiA:~ $ ssh pi@PiB
pi@PiB:~ $ python ... >myoutput.log
pi@PiB:~ $ less myoutput.log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.