if its modem to modem over a typical phone cable,
you should be able to use ATA and ATO (that's the letter not the number)
O - originate, A - answer
used to do this all the time, but it only works in pairs
if you want a proper exchange with multiple extensions or something
you'd have to do more work.
I also toyed with plugging modems into ATA voip adapters and connecting that way,
it was a bit weird and speeds weren't the greatest, but I did get it working in a
limited fashion
If both modems in a given connection are older
('80s), lower-speed
(300-1200/2400) it will likely work by simply connecting them together
and commanding one off-hook in answer mode (ATA ?), then the other
off-hook in originate mode (ATD ? ATH1 ?). I have successfully done
this with particular modems up to 14.4Kbps but might be forgetting the
commands.