1832574 Members
3586 Online
110043 Solutions
New Discussion

Re: xhost +

 
SOLVED
Go to solution
Sanjiv Sharma_1
Honored Contributor

xhost +

Using "find" or some other command I wish to search for all instances of the “xhost +” command from the system-wide
Xsession file, from user Xsession files, and from any application programs or
shell scripts that use the X window system. How can I achieve this? Looking for exact command/syntax.

Thanks in advance.
Everything is possible
7 REPLIES 7
Geoff Wild
Honored Contributor

Re: xhost +

for i in `find /home -type f -exec ls {} \;`
do
grep "xhost +" $i && echo $i
done


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Steven Schweda
Honored Contributor

Re: xhost +

The "exact command/syntax" depends on the
exact requirements. For example, how many
spaces between "xhost" and "+"? Exactly
which files do you wish to search?

> [...] any application programs [...]

Good luck. I'm sure that I could write one
which you'd never find.
spex
Honored Contributor

Re: xhost +

Here's a starting point:

$ find / -name 'Xsession' -o -name '*.sh' -print | xargs grep -l -E 'xhost\ +\+'

PCS
Sanjiv Sharma_1
Honored Contributor

Re: xhost +

This command gives me a message:

# find / -name 'Xsession' -o -name '*.sh' -print | xargs grep -l -E 'xhost\ +\+'
grep: can't open /opt/VRTS/bin/vxsvcctrl.sh

/opt/VRTS/bin/vxsvcctrl.sh is a link to a file which doesn't exist. Is there anyway I can ignore the check on this file?
Everything is possible
Sandman!
Honored Contributor
Solution

Re: xhost +

Negate all symbolic links by providing the "! -type l" command line switch to find(1):

# find / -name 'Xsession' -o -name '*.sh' ! -type l | xargs grep -l -E 'xhost\ +\+'
Sandman!
Honored Contributor

Re: xhost +

On second thoughts search only regular files and avoid all device files, fifos, sockets and links by using...

# find / -name 'Xsession' -o -name '*.sh' -type f | xargs egrep -l 'xhost +\+'
Sanjiv Sharma_1
Honored Contributor

Re: xhost +

Thanks a lot!
Everything is possible