in reply to
Open a telnet session with login using batch script
Without showing us the script you used, our only recourse is to use random guessing what you did
My guess is that you just printed YYYY and ZZZZZ on STDOUT and that didn't work because STDOUT of the script is not connected to STDIN of the script.
To do that you either use the module Expect (which is a general solution for scripts to call interactive command line programs, or Net::Telnet which is tailored especially to telnet communication. You can find both modules either in your local perl library or on CPAN