Ok, this is hard to distill to a single question because it really depends on how I'm going to troubleshoot it.
The following script is meant to pipe mount.cifs commands to a while loop that enters password for three password prompts. The commented out blocks are attempts to debug the fact that it isn't responding to the prompt.
#!/bin/bash
printf "How many atoms are there in the universe?\nAnswer:"
read -s $pwd
echo -e "\nThanks.\n"
while read prompt ; do
# printf "prompt = $prompt" > /dev/stdout
# ${prompt//"\n"/"\\n"}
# printf "prompt is" >foo
if [ "$prompt" = "Password: " ]; then
echo -e "$pwd\r\n" > /dev/stdin
fi
done < <(
sudo mount.cifs "//192.168.1.2/My Music" /home/pi/Desktop/Music -o user=Rob_
sudo mount.cifs "//192.168.1.2/My Videos" /home/pi/Desktop/Videos -o user=Rob_
sudo mount.cifs "//192.168.1.2/My Pictures" /home/pi/Desktop /Pictures -o user=Rob_
)
The 'prompt' variable does not seem to meet the condition, but the debug printouts are being swallowed up even after manually redirecting to /dev/stdout?
If someone could at the very least tell me how I can print debug info in this scenario I would be grateful, and if they want to tell me how to solve this problem outright (preferably by the method I was shooting for, but if you have a more elegant one I'd be interested to see it) then I'd appreciate that, too.
EDIT: For the record I'm aware that you can supply the password directly to the command, I'm just doing this as a test for myself.