I am using below script to count the files in a directory with name RTLOG_$DATE but this script is not working in SAM Template, Can some help me to modify the script correct so that I can get the output correctly and use in SAM
#!/usr/bin/perl
use strict;
use warnings;
my $date = `date +\%Y\%m\%d`;
chomp($date);
my $directory = "/u01/apps/resa/done.$date";
# Navigate to the directory
chdir($directory) or die "Cannot navigate to $directory: $!";
# Run the count command
my $count_command = "ls -lrt RTLOG_*_$date | wc -l";
my $count = `$count_command`;
# Output 1 if count is greater than 0, otherwise output 0
if ($count > 0) {
print "1\n";
} else {
print "0\n";
}