You're not using $expect
anywhere there. You have to run your command via $expect->spawn
so that your Expect object can handle things. And then you'll need some way of gathering its output (I'm thinking using $expect->log_file(...)
to set the log to a string filehandle or something).
Once you're using $expect->spawn
, then you can insert your password check. But there's no way you can do this with qx
(the backticks).