I use python libraries to check if dir exists or not during the automation to make sure my script will create the dir i want is not present locally. But what if i want to do the same thing remotely.
I found few posts showing the same stuff with paramiko's sftp and other ways. I'm ok with paramiko but i have to install it via pip install, i can't simple use paramiko library with out install like any other standard library. So i liked ssh way.
I use 'test' command remotely, let's see
if (sudo ssh -i /home/downloads/server.pem firstname.lastname@example.org -o "StrictHostKeyChecking no" 'test -d /home/ubuntu/test_dir'); then echo 'yes' fiwhich is working fine.