use strict; use warnings; use autodie; use Net::SSH::Expect; # ssh into a router my $ssh = Net::SSH::Expect->new( host => "ipaddr", password => 'user', user => 'pwd', raw_pty => 1, ); my $login_output = $ssh->login(); # execute the commands $ssh->exec("command 1"); $ssh->exec("command 2"); # open a file and read the config information open my $prep, '<', 'config.txt; while (my $config = <$prep>) { chomp $config; my $conf = $ssh->exec("$config"); print("$conf"); }