if ( defined($port) ) { print "\tSSH connection to server ($host) established!\n"; $cli->login(...); # or $cli->put(string => "IJAF\n"), if it's waiting for user input - whichever works. You can also use $cli->print(line => "IJAF"); } else { print "\tSSH connection to server ($host) could not be established... Exiting program.\n"; exit; }