I have a shell script in one server (Ubuntu) say server1, in which i create a folder in other server say server2. But the command for create directory is not working. Folder is not creating in server2 when i run the script. But if i run the script directly from commandline it creates folder in the server2. Here is the script file :
#!/bin/bash
sshpass -p 'xyz' ssh [email protected] '[ -d /var/www/html/Database/Backup/Backups/05-08-2018 ]'
if [[ $? -eq 0 ]]
then
echo 'Directory exists'
else
echo 'Not exists! Creatting'
sshpass -p 'xyz' ssh [email protected] "mkdir -p /var/www/html/Database/Backup/Backups/05-08-2018"
fi
What might be the problem here? Can anyone look into it and help me in resolving this.