1827295 Members
2446 Online
109717 Solutions
New Discussion

help in script

 
Jairo Campana
Trusted Contributor

help in script

I need execute this line and not work:
(this not response)
rsh 172.31.199.48 grep IITT@speedy.com.ar /opt/SUNWmsgsr/log/mail.log_current|grep EA |awk '{print $12}' |sort|uniq

========================================
(using ' ' )
rsh 172.31.199.48 grep 'IITT@speedy.com.ar /opt/SUNWmsgsr/log/mail.log_current|grep EA |awk '{print $12}' |sort|uniq'
awk: syntax error near line 1
awk: illegal statement near line 1


thanks
legionx
16 REPLIES 16
Steve McKenna_3
Advisor

Re: help in script

I'm guessing that you mean remsh or rexec (for remote commands) rather than rsh (restricted shell).

What O/S version is the server at 172.31.199.48? And what O/S are you running from?


...Steve...
Steve McKenna_3
Advisor

Re: help in script

A thought... maybe it's getting crossed up by the single quotes on the whole phrase and the single quotes for the awk? What if you use double quotes for the outside?
Steve McKenna_3
Advisor

Re: help in script

p.s. sort -u will eliminate one nesting level as well...
RAC_1
Honored Contributor

Re: help in script

grep 'IITT@speedy.com.ar /opt/SUNWmsgsr/log/mail.log_current|grep EA |awk '{print \$12}' |sort|uniq'

Escape $12 - \$12. also sort -u is enough.
There is no substitute to HARDWORK
Rick Garland
Honored Contributor

Re: help in script

When you grep for EA, are there 12 fields to awk from?

Also remember to use the shift function if you are looking for over $9 items.

With the sort command you can include the -u as this is the unique flag to sort.
Jairo Campana
Trusted Contributor

Re: help in script

steve:
double quotes for the outside not work

legionx
Steve McKenna_3
Advisor

Re: help in script

awk lets you address $12 directly. In the test I ran on 11i, if you try to address $12 and there is none, no error is generated, just null output.
Steve McKenna_3
Advisor

Re: help in script

I'm looking at your command again.. just saw something...

in the second example, shouldn't it be 'grep ~ rather than grep 'IITT~ ?
Jairo Campana
Trusted Contributor

Re: help in script

when execute the command in the server locally without rsh its work!!!
using $12 of awk

server locally:
##grep IITT@speedy.com.ar /opt/SUNWmsgsr/log/mail.log_current |grep " EA "|awk '{print $12}'|sort -u
output:
blinker@binker.com

its work

the problem is when use rsh
legionx
Jairo Campana
Trusted Contributor

Re: help in script

steve :using 'grep ~ not work

rsh 172.31.199.48 'grep IIT@speedy.com.a/opt/SUNWmsgsr/log/mail.log_current |grep " EA "|awk '{print $12}'|sort -u'
legionx
Jairo Campana
Trusted Contributor

Re: help in script

steve using : 'grep~
rsh 172.31.199.48 'grep IITT@speedy.com.a/opt/SUNWmsgsr/log/mail.log_current |grep " EA "|awk '{print $12}'|sort -u'
awk: syntax error near line 1
awk: illegal statement near line 1
legionx
Jim Butler
Valued Contributor

Re: help in script

write a script to rsh with called "doit"

on the first line, specify your shell (in the shebang line)

i.e.

#/bin/sh

grep `IITT@speedy.com.ar /opt/SUNWmsgsr/log/mail.log_current|grep EA |/bin/awk '{print $12}' |sort|uniq `

Note the changes in the first and last quote that I made -

anyway - chmod doit to 755 and place it on an accessible automount point, or... place it on the system.

then


rsh 172.31.199.48 -n /path_to/doit

good luck





Man The Bilge Pumps!
Jim Butler
Valued Contributor

Re: help in script

rsh 172.31.199.48 -n `grep "IITT@speedy.com.ar" /opt/SUNWmsgsr/log/mail.log_current | grep EA |awk '{print $12}' |sort|uniq `

If you want to use the rsh without "doit"

surround the execute string in the single tic's (the ~` key) and let her rip - that should work for you.

Man The Bilge Pumps!
Jairo Campana
Trusted Contributor

Re: help in script

doit no work
my log contains these data:
I need to obtain the field awk $12.

can replace "awk" by another command?

log:

19-Apr-2005 01:50:57.63 4b6f.1e14.25248 tcp_auth tcp_local EA 130 IITT@speedy.com.ar rfc822;IITT@speedy.com.ar IITT@speedy.com.ar <0IF600ECPG4IWF90@tdimso48.backend.tdata.com.ar> *IITT@speedy.com.ar

I need the field *IITT@speedy.com.ar
legionx
Jairo Campana
Trusted Contributor

Re: help in script

this works but the answer is very slow:
rsh 10.1.1.10 -n grep IITT@speedy.com.ar /opt/SUNWmsgsr/log/mail.log_current |grep " EA "|awk '{print $14}'|sort -u

without command |sort -u
rsh 10.1.1.10 grep IITT@speedy.com.ar /opt/SUNWmsgsr/log/mail.log_current |grep " EA "|awk '{print $12}'

this works, and the answer is very fast but the result is:
*IITT@speedy.com.ar
*IITT@speedy.com.ar
*IITT@speedy.com.ar
.
.

that I can do
thanks
legionx
Jairo Campana
Trusted Contributor

Re: help in script

thanks, solved:
this works but the answer is very slow:
rsh 10.1.1.10 -n grep IITT@speedy.com.ar /opt/SUNWmsgsr/log/mail.log_current |grep " EA "|awk '{print $12}'|sort -u

the filed $awk is $12
legionx