[HPADM] SUMMARY: weird remsh/awk behavior

From: Paveza, Gary (gary.paveza@AIG.COM)
Date: Wed Nov 05 2003 - 10:27:23 EST


Thanks to Bill for pointing me in the right direction. The solution turned
out to be very simple. Make sure that the $ in $2 is escaped.

remsh dhapp01 "who | awk '{print \$2}'"
---------------------------------------------------------
Gary Paveza, Jr.
Senior Systems Administrator -CSA
(302) 252-4831 - phone
(302) 377-1516 - cell

        -----Original Message-----
        From: Paveza, Gary
        Sent: Wednesday, November 05, 2003 10:21 AM
        To: 'HP9000 Admin'
        Subject: RE: [HPADM] weird remsh/awk behavior

        A couple of mentioned that I can remove the "" around the command
that remsh is executing. That works, however, the awk is actually being
done on the local machine then. This would be fine, except that what I'm
really trying to do is kill some processes on a remote system:

        remsh <remote> "ps -fu <user> | grep <program> | grep -v grep | awk
'{print $2}' | xargs kill -15"

        So, the entire command has to be on the remote system.
        ---------------------------------------------------------
        Gary Paveza, Jr.
        Senior Systems Administrator -CSA
        (302) 252-4831 - phone
        (302) 377-1516 - cell

                -----Original Message-----
                From: Paveza, Gary [SMTP:gary.paveza@AIG.COM]
                Sent: Wednesday, November 05, 2003 9:57 AM
                To: 'HP9000 Admin'
                Subject: [HPADM] weird remsh/awk behavior

                Has anyone noticed the following remsh/awk behavior and if
so, a workaround?

                Issuing who on the local machine works as expected.

                $ who
                dmullins pts/ta Nov 2 13:10
                npathil pts/tb Nov 3 16:30
                cdigrego pts/tc Nov 5 05:18

                Issuing who on the local machine and using awk to print out
just the user
                name works as expected.

                $ who | awk '{print $1}'
                dmullins
                npathil
                cdigrego

                Using remsh to issue who on a remote machine works as
expected.

                $ remsh dhapp01 "who"
                plpcd5 pts/ta Nov 5 09:21
                gpaveza pts/tc Nov 5 09:27

                Using remsh to issue a who on a remote machine and using awk
to print out
                just the user name fails to work.
                 
                $ remsh dhapp01 "who | awk '{print $1}'"
                sh: 1: Parameter not set.

                ---------------------------------------------------------
                Gary Paveza, Jr.
                Senior Systems Administrator -CSA
                (302) 252-4831 - phone
                (302) 377-1516 - cell

                --
                             ---> Please post QUESTIONS and SUMMARIES only!!
<---
                        To subscribe/unsubscribe to this list, contact
majordomo@dutchworks.nl
                       Name: hpux-admin@dutchworks.nl Owner:
owner-hpux-admin@dutchworks.nl
                 
                 Archives: ftp.dutchworks.nl:/pub/digests/hpux-admin
(FTP, browse only)
                            http://www.dutchworks.nl/htbin/hpsysadmin
(Web, browse & search)

--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:36 EDT