How to check it on a remote machine?

Posted on 2006-10-25
Last Modified: 2010-04-20


How can I run

                         if [ -e $SOME_PAH ]

on a remote machine as I do on a local?

I tried  ssh  $REMOTE_MACHINE  ls  $SOME_PATH which works fine but I think it is no reliable. Also I tried

fyn = `  ssh $REMOTE_MACHINE [ -e $SOME_PATH] $$ echo y `

but does'nt work!

any comments or advice?

Question by:akohan

Author Comment

ID: 17807914

It was funny since the second statement now it is working!!!  I had left a space after and after equal sign!

However, does anybody can give me a better way?

LVL 24

Accepted Solution

slyong earned 63 total points
ID: 17808305

fyn=`ssh $REMOTE_MACHINE "[ -e $SOME_PATH ] && echo y"`

should work just fine.. may be is the " thing
LVL 48

Assisted Solution

Tintin earned 62 total points
ID: 17808454

if [ -n "`ssh $REMOTE_MACHINE \"[ -e $SOME_PATH ] && echo y`\"" ]

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now