views:

762

answers:

1

I am trying to verify if a directory exists prior to moving a file in Korn, using the classic:

    if [[ -d ${dir} ]]; then
        scp file
    else
        exit 12
    fi

My Problem:
That the directory is on another server, so whenever I check, the script can't find it and therefore fails and exits every time.
My Question:
Is there a way to do a "-d" across the network, perhaps using sftp/scp-like functionality? The user currently does not have to enter a password and can scp fine, so that is one less issue.

+2  A: 

How about

ssh user@host test -d ${dir}
eduffy
Thanks much...worked out perfectly, just did:ssh user@host test -d ${dir} if [[ $? -eq 0 ]]; then etc...
Sean
`if ssh ...; then ` should work as well .. if you prefer one-liners.
eduffy

related questions