in reply to logging into 2 boxes with Net::Expect::ssh and 1 script
You are not doing a login() for the second session before attempting a command. When I added $login_input = $ssh2->login(); at line 90, I got no errors (although I did comment out all of your command stuff).