0

I have a systemd service file that runs a java program in another tty

[Unit]
Description=java program
After=network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/java -cp "/home/user/someclass.jar"
Restart=always
RestartSec=10
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit
TTYPath=/dev/tty10
TTYVTDisallocate=yes
TTYReset=yes
TTYVHangup=yes

[Install]
WantedBy=multi-user.target

The program waits for input in the tty, I can change to that tty by using Ctrl+Alt+F10 or using chvt 10 and I'm able to interact with the program.

Now I want to send input and get output from that tty without changing my current tty. I tried using screen and all I get is a blank screen and. I tried using script which succeeded if I run bash in that tty but fails If i run a java program

1 Answers1

0

The PTY feature of socat may be your best bet for interfacing terminal-heavy apps programmatically w/o any extra functionality. See the examples in the man page.

Also, dtach provides screen-like (multi-way) reattachment semantics for easy access from a terminal emulator.

L29Ah
  • 823
  • Can you provide an example of socat to run on /dev/tty10? Also looking at the man page of dtach I see no mention of dtach working with ttys, only sockets. – MOHAMMAD RASIM Mar 06 '18 at 12:19