I used to do uears ago I/O with different lines on RS-232 ports ans parallel ports in different PCs. Nowdays serial and parallel ports have almoat completely dissappeared, being often replaced with USB adapters in applications where they are needed.
USB2Serial Adapter As An I/O Device article tells how USB adapters can be used for hardware hacking. The solution is to use a USB to Serial Adapter as an I/O device (Spanish, translated here). There is a C program for Linux, SioFus (Simple Input Output from USB2SERIAL), that converts a simple USB to Serial Port Adapter into an I/O device with 4 inputs and 2 outputs. It’s simple and gets the job done. The code uses ioctl and allows DCD, DSR, CTS and RI to act as inputs while DTR and RTS act as outputs. These pins then likely control transistors that switch the relays. The SioFus code is available on github.