Find not finding stuff if run remotely

Hello
I'm working on script to find tomcat on all my servers. Then find out what version of tomcat is installed. Basically I want to check and see if the latest version is installed. I'm testing the script on Solaris 10. I'm also going to need it to work on RHEL and SLES.

If I run the following find command remotely, It doesn't find the file. If I run it on the server locally it it finds this file: /usr/serena/vm/common/tomcat/bin/version.sh

Local command

sudo find / \( -name 10_Recommended* -o -name share \) -prune -o -type f -name version.sh -print 2>/dev/null

The script

for s in `cat sol`
do echo $s
ssh -q  $s sudo find / \( -name 10_Recommended* -o -name share \) -prune -o -type f -name version.sh -print 2>/dev/null
done

Can someone tell me why this is happening?

The \( becomes a ( without the \ when you send it via ssh that way. Try surrounding everything with single-quotes to send it literally. Also, 10_reccommended* really ought to be quoted there.

Also, that's a useless use of cat. Use a while read loop and use ssh -n.

while read s
do
        echo $s
        ssh -n -q  $s sudo 'find / \( -name "10_Recommended*" -o -name share \) -prune -o -type f -name version.sh -print 2>/dev/null'
done < sol
2 Likes

Corona688,
Thanks for replying. Tried did what you said, but I'm still not getting anything. It just prints out the hostnames in the file. It looks like it is not doing the search.

If I surround the find command with ' and 10_Recomended with " my for loop now works.

Thanks for your help.

Check that you have passwordless sudo access for these machines. It might be trying to ask for a password, seeing no terminal, and giving up.

My ssh-agent is working fine.

That has nothing to do with sudo.

I can sudo without a password and I even put the full path of sudo in the find command.

Anyway, my for loop works fine with your suggested modifications. I just can't get the while loop to work. You more or less gave me the answer.

Okay. If you post the exact code you use, I can try and tell what's wrong with it. Or just leave it.