in reply to Run an interactive shell command from Perl script
There is a Perl module for it (https://metacpan.org/pod/Expect).