Check to see if a directory exists remotely (shell script)

Is there a way to see if a directory exists on a remote server?

Perhaps there's a better way, but I'm writing an application deployment script, and I want to create a directory on a remote server if the directory doesn't exist to place the files.

Thanks in advance!


You can use ssh to call a programme on the remote host, test tests for certain conditions.

if [[ `ssh [email protected] test -d /path/to/my/directory && echo exists` ]] ; then
    # put code in here
fi

Just use

ssh remoteHost 'mkdir -p /whatever/your/dir/is'

It will create the dir if it doesn't already exist.