Automated-ar.sh
#!/bin/bash
# Ask which script to run
echo "Which script do you want to run?"
echo "1. generateHVReport.sh"
echo "2. generateTOReport.sh"
read -p "Enter the number of your choice: " choice
# Determine which script to run based on user input
if [ "$choice" -eq 1 ]; then
cd /home/nagios/AvailabilityReports/
script_to_run="./generateHVReport.sh"
elif [ "$choice" -eq 2 ]; then
cd /home/nagios/AvailabilityReports/
script_to_run="./generateTOReport.sh"
else
echo "Invalid choice. Exiting."
exit 1
fi
# Run the selected script and wait for its completion
$script_to_run
if [ $? -ne 0 ]; then
echo "The selected script ended with an error."
exit 1
fi
## Copy the necessary file
#cp /path/to/source/file /path/to/destination/file
#if [ $? -ne 0 ]; then
# echo "Error copying the file."
# exit 1
#fi
# Find the .csv file in the specified directory
csv_file=$(ls /home/nagios/AvailabilityReportsConvert/output/*.csv 2>/dev/null | head -n 1)
if [ -z "$csv_file" ]; then
echo "No .csv file found in /home/nagios/AvailabilityReportsConvert/output."
exit 1
fi
# Open the .csv file in Vim for editing and wait for the completion
vim "$csv_file"
# Run the second script and wait for its completion
cd /home/nagios/AvailabilityReportsConvert
./makePDF.sh
if [ $? -ne 0 ]; then
echo "The second script ended with an error."
exit 1
fi
echo "All tasks completed successfully."