Re: [Hampshire] Pipe issues

2009-08-05 Thread Chris Dennis
Simon Reap wrote:
> 
> (BTW, did anyone else read the subject of this email and assume it was 
> carrying on the armoured ethernet thread?)

No, I thought it was about smoking.  Virginia shag, anyone?

cheers

Chris
-- 
Chris Dennis  cgden...@btinternet.com
Fordingbridge, Hampshire, UK

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--


Re: [Hampshire] Pipe issues

2009-08-05 Thread Leo
Andy Smith wrote:
> Hi Leo,
> 
> On Wed, Aug 05, 2009 at 09:05:42PM +0100, Leo wrote:
>> Still don't understand why anacron requires my script to have it though, 
>> when the script works fine when called directly from the command line.
> 
> I'd love to know why this ever worked.  Things like that bother me.
> As far as I am aware, "\s" isn't anything special in a basic or
> extended regular expression, only a Perl one, and you'd need to do
> grep -P to enable those.
> 
> What shell do you use on the command line? (echo $SHELL)
> 
> What's in your environment? ("set" - then maybe put the output in a
> pastebin like pastie.org)
> 
> Or have I missed something obvious?
> 
> Cheers,
> Andy
> 
> 

I'm using the debian standard shell, so bash. And I haven't knowingly 
changed anything in the environment.

Sorry, what is a pastebin - I haven't come across it before.

Leo

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--


Re: [Hampshire] Pipe issues

2009-08-05 Thread Andy Smith
Hi Leo,

On Wed, Aug 05, 2009 at 09:05:42PM +0100, Leo wrote:
> Still don't understand why anacron requires my script to have it though, 
> when the script works fine when called directly from the command line.

I'd love to know why this ever worked.  Things like that bother me.
As far as I am aware, "\s" isn't anything special in a basic or
extended regular expression, only a Perl one, and you'd need to do
grep -P to enable those.

What shell do you use on the command line? (echo $SHELL)

What's in your environment? ("set" - then maybe put the output in a
pastebin like pastie.org)

Or have I missed something obvious?

Cheers,
Andy

-- 
http://bitfolk.com/ -- No-nonsense VPS hosting

"Greatness sits upon my shoulders as the dog urinates upon the pavement -
 with naturalness and ease and some offence to passers-by."
 -- The League Against Tedium


signature.asc
Description: Digital signature
-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--

Re: [Hampshire] Pipe issues

2009-08-05 Thread Leo
Hugo Mills wrote:
> On Tue, Aug 04, 2009 at 10:18:32PM +0100, Leo wrote:
> 
>I have a thought... is this program normally run interactively? If
> so, does it present a countdown of remaining time or bytes? If so,
> it's quite likely that it's using CR, reverse tabs, or other control
> characters to overwrite the previous line. If it's doing that, you'll
> probably find that grep isn't handling the output right.
> 
>You could try something like this:
> 
> program | tr [[:cntrl:]] \\n | grep -E -v remaining[[:space:]]*$
> 
>Hugo.
> 

Worked brilliantly! thank you :)

Still don't understand why anacron requires my script to have it though, 
when the script works fine when called directly from the command line.

Leo

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--


Re: [Hampshire] Pipe issues

2009-08-04 Thread Leo
Hugo Mills wrote:
> 
>I have a thought... is this program normally run interactively? If
> so, does it present a countdown of remaining time or bytes? If so,
> it's quite likely that it's using CR, reverse tabs, or other control
> characters to overwrite the previous line. If it's doing that, you'll
> probably find that grep isn't handling the output right.
> 
>You could try something like this:
> 
> program | tr [[:cntrl:]] \\n | grep -E -v remaining[[:space:]]*$
> 
>Hugo.
> 

Yes it does present a countdown and the "... remaining" only appears on 
the one line. I will give your suggestion a try tomorrow as the computer 
it runs on is down now.

Thank you,
Leo

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--


Re: [Hampshire] Pipe issues

2009-08-04 Thread Hugo Mills
On Tue, Aug 04, 2009 at 10:18:32PM +0100, Leo wrote:
> Bob Dunlop wrote:
> > 
> > Whos turning the \s into a space I wonder ?
> > 
> > It's not a bash syntax that I recognise, nor a grep one ?
> > 
> > Are you using csh for your interactive session ?
> > 
> > Try the following in your script.
> > 
> > program | grep -E -v "remaining[[:space:]]*$"
> > 
> > That's a combination I know works with grep regardless of the shell used.
> > Don' forget the -E
> > 
> 
> I got the syntax from reading man perlrequick. Unfortunately the new 
> syntax you specify doesn't help. Thanks though.

   I have a thought... is this program normally run interactively? If
so, does it present a countdown of remaining time or bytes? If so,
it's quite likely that it's using CR, reverse tabs, or other control
characters to overwrite the previous line. If it's doing that, you'll
probably find that grep isn't handling the output right.

   You could try something like this:

program | tr [[:cntrl:]] \\n | grep -E -v remaining[[:space:]]*$

   Hugo.

-- 
=== Hugo Mills: h...@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
  --- I'm all for giving people enough rope to shoot themselves in ---   
   the foot -- Andreas Dilger


signature.asc
Description: Digital signature
-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--

Re: [Hampshire] Pipe issues

2009-08-04 Thread Leo
Simon Reap wrote:
> 
> I would put the grep string in single quotes - anacron may be messing up 
> the trailing $
> 
> (BTW, did anyone else read the subject of this email and assume it was 
> carrying on the armoured ethernet thread?)
> 

That didn't help either, but it did give me an idea. I did a ps -ef 
while anacron was getting my script to run and noticed this:
grep -v remaining\s*$

without quotes, so I've now changed my script to try:
program | grep -v \"remaining\\s*$\"
and
program | grep -v \'remaining\\s*$\'

which means ps -ef gives
grep -v "remaining\s*$"
and
grep -v 'remaining\s*$'

However it still doesn't work when run from anacron :(

(Sorry for the confusion)

Leo

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--


Re: [Hampshire] Pipe issues

2009-08-04 Thread Leo
Bob Dunlop wrote:
> 
> Whos turning the \s into a space I wonder ?
> 
> It's not a bash syntax that I recognise, nor a grep one ?
> 
> Are you using csh for your interactive session ?
> 
> Try the following in your script.
> 
> program | grep -E -v "remaining[[:space:]]*$"
> 
> That's a combination I know works with grep regardless of the shell used.
> Don' forget the -E
> 

I got the syntax from reading man perlrequick. Unfortunately the new 
syntax you specify doesn't help. Thanks though.

Leo

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--


Re: [Hampshire] Pipe issues

2009-08-04 Thread Leo
Unfortunately that didn't make a difference.

Jim Kissel wrote:
> 
> 
> Leo wrote:
>> I've got a shell script that calls a program and pipes its output to 
>> grep, i.e.
>>
>> #!/bin/bash
>> 
>> program | grep -v "remaining\s*$"
>> 
>>
>> When I run the script this works fine (i.e. no lines output ending in 
>> remaining). However if I set the script to run using anacron then I 
>> always get an email with loads of lines with "remaining" on the end of 
>> them. I've tried loads of things to attempt to debug it, but to no 
>> avail. Can anyone help?
>>
> set $PATH just after #!/bin/bash to what ever your local environment has 
> it set to.
> 
> YMMV
> 

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--


Re: [Hampshire] Pipe issues

2009-08-04 Thread Bob Dunlop
On Tue, Aug 04 at 08:56, Leo wrote:
> I've got a shell script that calls a program and pipes its output to 
> grep, i.e.
> 
> #!/bin/bash
> 
> program | grep -v "remaining\s*$"
> 
> 
> When I run the script this works fine (i.e. no lines output ending in 
> remaining). However if I set the script to run using anacron then I 

Whos turning the \s into a space I wonder ?

It's not a bash syntax that I recognise, nor a grep one ?

Are you using csh for your interactive session ?

Try the following in your script.

program | grep -E -v "remaining[[:space:]]*$"

That's a combination I know works with grep regardless of the shell used.
Don' forget the -E

-- 
Bob Dunlop

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--


Re: [Hampshire] Pipe issues

2009-08-04 Thread Simon Reap
Leo wrote:
> #!/bin/bash
> 
> program | grep -v "remaining\s*$"
> 
>   

I would put the grep string in single quotes - anacron may be messing up 
the trailing $

(BTW, did anyone else read the subject of this email and assume it was 
carrying on the armoured ethernet thread?)

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--


Re: [Hampshire] Pipe issues

2009-08-04 Thread Jim Kissel


Leo wrote:
> I've got a shell script that calls a program and pipes its output to 
> grep, i.e.
> 
> #!/bin/bash
> 
> program | grep -v "remaining\s*$"
> 
> 
> When I run the script this works fine (i.e. no lines output ending in 
> remaining). However if I set the script to run using anacron then I 
> always get an email with loads of lines with "remaining" on the end of 
> them. I've tried loads of things to attempt to debug it, but to no 
> avail. Can anyone help?
> 
set $PATH just after #!/bin/bash to what ever your local environment has 
it set to.

YMMV

-- 
Life is too short.

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--


[Hampshire] Pipe issues

2009-08-04 Thread Leo
I've got a shell script that calls a program and pipes its output to 
grep, i.e.

#!/bin/bash

program | grep -v "remaining\s*$"


When I run the script this works fine (i.e. no lines output ending in 
remaining). However if I set the script to run using anacron then I 
always get an email with loads of lines with "remaining" on the end of 
them. I've tried loads of things to attempt to debug it, but to no 
avail. Can anyone help?

Thank you,
Leo

-- 
Please post to: Hampshire@mailman.lug.org.uk
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--