This is really basic, but I'm new to this. So basically I've created a random string using date below, but I can't really figure out how to set that string as the password. I know I have chpasswd <<< "$username:$password", but the string is not set as $password right? The error code I'm getting is "password is referenced but not assigned". Btw, this is part of a larger script.
# User enters username without being
# prompted for it
read -p "$1" username
# User enters full name without being prompted
read -p "$2" full_name
# Get a random password
date +%s%N | sha256sum | head -c 10 # Use this string as password
# Creates an account
useradd "$username"
# Assign the password.
chpasswd <<< "$username:$password"