Skip to content

Commit 5675c80

Browse files
committed
Wget error handling for unit5
1 parent 5c435d9 commit 5675c80

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

Scripts/unit5_lab.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,16 @@ if [ ! -d "$HOME/tmp_splunk" ]; then
5252
mkdir -p "$HOME/tmp_splunk"
5353
fi
5454

55+
# Initialize a flag to indicate success
56+
all_success=true
57+
5558
# Download the files
56-
wget "${scripts_repo}unit5/netflix_titles.csv" -O "$HOME/tmp_splunk/netflix_titles.csv"
57-
wget "${scripts_repo}unit5/Top Video Game sales.csv" -O "$HOME/tmp_splunk/Top Video Game sales.csv"
58-
wget "${scripts_repo}unit5/webauth.csv" -O "$HOME/tmp_splunk/webauth.csv"
59+
wget "${scripts_repo}unit5/netflix_titles.csv" -O "$HOME/tmp_splunk/netflix_titles.csv" || all_success=false
60+
wget "${scripts_repo}unit5/Top Video Game sales.csv" -O "$HOME/tmp_splunk/Top Video Game sales.csv" || all_success=false
61+
wget "${scripts_repo}unit5/webauth.csv" -O "$HOME/tmp_splunk/webauth.csv" || all_success=false
5962

6063
# Verify download was successful
61-
if ! [ "$HOME/tmp_splunk/webauth.csv" ]; then
64+
if [ "$all_success" = false ]; then
6265
echo -e "${red}[UNIT 1 LAB]${none} Error: Could not download Splunk files to $HOME/tmp_splunk folder"
6366
echo -e "${red}[UNIT 1 LAB]${none} Try downloading manually from ${scripts_repo}unit5 and placing in ~/tmp_splunk."
6467
exit 1

Scripts/unit5_project.sh

+8-5
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ if [ ! -d "$HOME/tmp_splunk" ]; then
1111
mkdir -p "$HOME/tmp_splunk"
1212
fi
1313

14+
# Initialize a flag to indicate success
15+
all_success=true
16+
1417
# Download the files
15-
wget "${scripts_repo}unit5/webserver02.csv" -O "$HOME/tmp_splunk/webserver02.csv"
16-
wget "${scripts_repo}unit5/uploadedhashes.csv" -O "$HOME/tmp_splunk/uploadedhashes.csv"
17-
wget "${scripts_repo}unit5/failedlogins64.csv" -O "$HOME/tmp_splunk/failedlogins64.csv"
18-
wget "${scripts_repo}unit5/BlueCoatProxy01.csv" -O "$HOME/tmp_splunk/BlueCoatProxy01.csv"
18+
wget "${scripts_repo}unit5/webserver02.csv" -O "$HOME/tmp_splunk/webserver02.csv" || all_success=false
19+
wget "${scripts_repo}unit5/uploadedhashes.csv" -O "$HOME/tmp_splunk/uploadedhashes.csv" || all_success=false
20+
wget "${scripts_repo}unit5/failedlogins64.csv" -O "$HOME/tmp_splunk/failedlogins64.csv" || all_success=false
21+
wget "${scripts_repo}unit5/BlueCoatProxy01.csv" -O "$HOME/tmp_splunk/BlueCoatProxy01.csv" || all_success=false
1922

2023
# Verify download was successful
21-
if ! [ "$HOME/tmp_splunk/BlueCoatProxy01.csv" ]; then
24+
if [ "$all_success" = false ]; then
2225
echo -e "${red}[UNIT 1 LAB]${none} Error: Could not download Splunk files to $HOME/tmp_splunk folder"
2326
echo -e "${red}[UNIT 1 LAB]${none} Try downloading manually from ${scripts_repo}unit5 and placing in ~/tmp_splunk."
2427
exit 1

0 commit comments

Comments
 (0)