I am completely new to bash scripting. I am trying to write a bash script to copy the files from a staging to multiple production servers.
I am using three files for the same.
serverPass.txt : Contains multiple server ips along with their passwords (Space separated).
paths.txt : Contain paths where files need to be copied at each server mentioned in
serverPass.txtcopy.sh : The bash script file.
copy.sh :
#!/bin/bash
while read SERVER PASSWORD;
do
while read PATH;
do
sshpass -p "$PASSWORD" scp * "$SERVER":"$PATH"
done <./paths.txt
done <./serverPass.txt
The output that I am getting is :
sshpass: command not found
But sshpass has already been installed and working fine when used directly into the command line. What am I doing wrong?
Output of whereis and which :
dmtntimespacedev1:/usr/local/tempcheck/Test # whereis sshpass
sshpass: /usr/bin/sshpass /usr/share/man/man1/sshpass.1.gz
dmtntimespacedev1:/usr/local/tempcheck/Test # which sshpass
/usr/bin/sshpass
whereis sshpassand/orwhich sshpassfrom your command line.