I am working on a script to get list of files from remote servers, each remote server has its own password, IP and user and path. That's why I am using sshpass to pass the password parameter dynamically. Here is my script to just get list of files for time being:
user='username'
pass='password' ->>> LOCATION_OF_REMOTE='hostpath'
ip='hostip'
path='hostpath'
data=`/usr/bin/sshpass -p $pass sftp -oBatchMode=no -b - -oStrictHostKeyChecking=no $user@$ip <<_EOF_
cd $path
ls
_EOF_`
echo $data >> list_of_files.txt
When I run this script I am getting error:
ERROR: sshpass: Failed to run command: No such file or directory
while exact same command works fine outside the script on command line. It just doesn't work when it's within the script. I tried to run this as root and non root use both. I don't know why it doesn't work from within the script.