I want to check via sftp only (not ssh) if a directory exists before creating it. The only solutions I have found so far are using ssh but I need to use sftp only due to permission-ing issues - does anyone know a way?
sftp_put () {
sftp -oidentityfile=/home/user/.ssh/host_usersftp usersftp@$1 <<EOF
-- Add a check here e.g -- IF exist $2 ( echo $2 exists ) ELSE ( echo create $2 )
mkdir $2
cd $2
put $3
EOF
}
lsof that folder and check the answer. And seeing your code, if the folder does not exist, you create it... just try to create it and ignore errors (in case it exists).