LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Passwordless SSH access

[ILUG] Passwordless SSH access

John Tobin tobinjt at netsoc.tcd.ie
Wed Mar 20 11:37:48 GMT 2002


On Wed, Mar 20, 2002 at 09:33:06AM +0000, Niall O Broin wrote:
> On Wed, Mar 20, 2002 at 12:11:30AM +0000, Ronan Waide wrote:
> [root at dunlop modules]# ps ax | grep foo
> 14801 pts/0    S      0:00 grep foo
> [root at dunlop modules]# ps ax | grep [f]oo
> [root at dunlop modules]#
> 
> What is it about grep and RE that causes this behaviour ? (note that the
> above example is not always correct. For example, 

The command line as shown by ps will be "grep [f]oo", which doesn't
match "foo".

> niall at bagend:~ >ps -ax|grep [f]oo
>  1944 pts/8    S      0:00 grep foo
> 
> but if you ensure that grep sees the RE like this
>  
> niall at bagend:~ >ps -ax|grep "[f]oo"
> niall at bagend:~ >
> 
> it's fine)

Do you by any chance have a file called foo in that directory?  bash
expands '[abcd]xxx' to 'axxx bxxx cxxx dxxx' ( quotes are for clarity
only ) if at least one of those files exists.  But when you quote the
argument filename expansion isn't performed on it.

> Does grep manipulate its arguments as saved or what ? Because I called my
> script ssh-agent-setup I matched on  "$USER.*ssh-agent$" and that works also
> (i.e. ps|grep doesn't find the grep) but leaving out the $ doesn't work

Because the $ is present in the command line as shown by ps.
Open two terminals and try this:
Terminal 1: ( ps auxwww; sleep 10 ) | grep "${USER}.*ssh-agent$"
Terminal 2 ( while the previous command is still running ): ps auxwww > file
Then take a look through file; you'll see something like ( wrapped ):
tobinjt   4568  0.1  0.1 1136  880 pts/37   S 11:26:23  0:00 grep
tobinjt.*ssh-agent$
Note the $ after ssh-agent so it doesn't match the RE.

> So, ps|grep won't match the grep when grep uses certain kinds of RE - oh
> lordy ! I'm leaving my grep -v grep in, thank you, in case the kind of RE is
> dependent on the phase of the moon :-)
> 
> Niall

-- 
John
"That would preempt a bunch of problems involved in trying to reconstruct
exactly how the Perl 5 parser thinks, which nobody entirely understands."
			Larry Wall, 2001/04/20, perl6-language at perl.org
"Finger to spiritual emptiness underlying everything." -- How a Japanese C
manual referred to a "pointer to void".




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell