If Condition failing inside ssh

Viewed 45

Hi I tried below code

ssh $p_ftp_user@$IP $SPATH
if [$? -eq 0]; then echo "ok" else echo "test" | mailx -r test@gmail.com -s "File Failure" $v_email_id fi

i want to check if $SPATH in same session if command is success then ok if not mail has to be sent . But i tried multiple ways with if but getting error message as "then unmatched" , if [$? -eq 0] then echo "ok" , if ; is removed it is saying "if unmatched". Please let me know how i can resolve this issue.

0 Answers
Related