お試しChatoGPT
#!/bin/bash
# Path to the CSV file containing hostname, user_id, password entries (comma-separated)
file_path="ftp_credentials.csv"
# Read the file line by line
while IFS= read -r line || [[ -n "$line" ]]; do
# Split the line using commas as separators
IFS=',' read -ra fields <<< "$line"
hostname="${fields[0]}"
user_id="${fields[1]}"
password="${fields[2]}"
# Attempt FTP login
echo "Attempting login to $hostname with user $user_id..."
if ftp -inv $hostname <user $user_id $password
quit
EOF
then
echo "Login successful!"
else
echo "Login failed!"
fi
echo "----------------------------------------"
done < "$file_path"
#!/bin/bash
# Path to the CSV file containing hostname, user_id, password entries (comma-separated)
file_path="ftp_credentials.csv"
# Path to the log file for exporting the test results
log_file="ftp_login_test.log"
# Clear the log file before starting the test
> "$log_file"
# Read the file line by line
while IFS= read -r line || [[ -n "$line" ]]; do
# Split the line using commas as separators
IFS=',' read -ra fields <<< "$line"
hostname="${fields[0]}"
user_id="${fields[1]}"
password="${fields[2]}"
# Attempt FTP login and export logs to the log file
echo "Attempting login to $hostname with user $user_id..." | tee -a "$log_file"
if ftp -inv $hostname <user $user_id $password
quit
EOF
then
echo "Login successful!" | tee -a "$log_file"
else
echo "Login failed!" | tee -a "$log_file"
fi
echo "----------------------------------------" | tee -a "$log_file"
done < "$file_path"