my $backup_host = "tftpserver.somewhere.net"; my $device = "cisco.somewhere.net"; my $type = "router"; # or "switch"; my $ios_version = 12; my @out; if ($type eq "router") { if ($ios_version >= 12) { @out = $session->cmd("copy system:/running-config " . "tftp://$backup_host/$device-confg\n\n\n"); } elsif ($ios_version >= 11) { @out = $session->cmd("copy running-config tftp\n$backup_host\n" . "$device-confg\n"); } elsif ($ios_version >= 10) { @out = $session->cmd("write net\n$backup_host\n$device-confg\n\n"); } } elsif ($type eq "switch") { @out = $session->cmd("copy system:/running-config " . "tftp://$backup_host/$device-confg\n\n\n"); }