my $output = `command`; print $logFile $output; # or my $logFile = "path/to/loge/file"; system("command >> $logFile");