#!C:/Perl64/bin/perl.exe use strict; use warnings; use Control::CLI; my $cli; my $output; my $temp; my $junk; #my $host = "1.11.1.11"; my $host = "1.12.1.12"; $cli = new Control::CLI( Use => 'SSH', Timeout => 180, ); $cli->connect( Host => $host, Username => 'user', Password => 'pass', ); $output = $cli->cmd("clear"); $output = ""; my $hostname = $cli->cmd("hostname | sed \'s/-.*//g\'"); print "hostname: $hostname"; $junk = $cli->print("su -c \"/some/dir/path/here/command.py -o /dir\""); $output = $cli->cmd("rootpwd"); print "\n$output\n"; #if ( $output =~ m/.*$hostname.ext.*/s && $output =~ m/.*name.ext.*/s ) { if ( $output =~ m/$hostname/s ) { print "\t$hostname.ext and name.ext created successfully on server in /spdata...\n"; } else { print "\tThere was a problem generating $hostname.ext and name.ext on server in /spdata... Please investigate and start application again... Exiting program.\n"; exit; } $cli->disconnect;