#!/usr/bin/perl use 5.010; use strict; use warnings; main(@ARGV); sub get_host # Collect the host name from a text file { open(HOST, '<', 'hosts.txt') or error("cannot open file ($!)"); my @host = ; return "@host\n"; } sub get_logon # Collect logon ID from keyboard { my $logon; print "Please Enter Logon ID:\n"; chomp ($logon =<>); return $logon; } sub get_psswd # Collect password from keyboard { my $psswd; print "Please Enter Password for hostID:\n"; chomp ($psswd =<>); return $psswd; } sub get_command # Collect the commands from a text file { open(CMD, '<', 'cmds.txt') or error("cannot open file ($!)"); my @cmd = ; return @cmd; } sub main # Command execution and export data to local file { my @host = get_host(); print @host; print "\n"; my $logon = get_logon(); print $logon; print "\n"; my $psswd = get_psswd(); print $psswd; print "\n"; my @cmds = get_command(); print @cmds; my $output = qx(cmd); open my $OUTPUT, '>>' , 'devbfs51chassisshow.txt' or die " Couldn't open output.txt: $!\n"; print "1plink -ssh -pw $psswd -l $logon @host @cmds"; }