checking the file existence using ssh

Hi

Can any body say me the reason for below error

ssh -o 'StrictHostKeyChecking no' user@client '[ -f /tmp/processclient.lck ] && print "1"'

I am getting error as "Missing ]":wall:

Try test condition with [[ and ]] this,

ssh -o 'StrictHostKeyChecking no' user@client '[[ -f /tmp/processclient.lck ]] && echo "1"'

I cannot reproduce it, could you post the exact command and output, just copy/paste from your terminal?

Still getting the same error

---------- Post updated at 07:46 AM ---------- Previous update was at 07:43 AM ----------

Hi radoulov:
Below is the copy from my terminal

$ ssh -o 'StrictHostKeyChecking no' rrameshs@psl164 '[ -f /tmp/processclient.lck ] && print "1"'  
                THIS IS A PRIVATE COMPUTER SYSTEM --- 
         USAGE MAY BE MONITORED AND UNAUTHORIZED ACCESS 
       OR USE MAY RESULT IN CRIMINAL OR CIVIL PROSECUTION 
     Except for some privacy rights granted by applicable law,
          by signing on to the system you acknowledge:
You do not have any expectation of privacy in your use of the system.  
You are familiar with, understand, accept, and will comply with the
           provisions of the Company Directive B-109

     
Missing ]

$

Does the following command work?

ssh -o 'StrictHostKeyChecking no' rrameshs@psl164 date

---------- Post updated at 01:51 PM ---------- Previous update was at 01:47 PM ----------

Ignore the previous question.
Most likely the remote user rrameshs@psl164 uses [t]csh as its default shell.
You should use a different syntax:

if ( -e /tmp/processclient.lck ) echo 1
1 Like

Thanks radoulov

It Worked .For our systems csh is the default.

May I know how should i remote execute in ksh . Because we have a series of shells which needs to be executd in ksh.

You could try:

ssh -o 'StrictHostKeyChecking no' rrameshs@psl164 ksh -c 'your_commands_here'