Scripting - Aix

This is a discussion on Scripting - Aix ; I am trying to read from a file for the list of servers and then instruct the script to login on these servers and run a command to check one text file. So far its done the below way... cat ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: Scripting

  1. Scripting

    I am trying to read from a file for the list of servers and then
    instruct the script to login on these servers and run a command to
    check one text file.

    So far its done the below way...

    cat server-list | \
    while read line
    do
    echo "------------------------------------------------" >>test.out
    echo " HOST : $line" >>test.out
    echo "________________________________________________" >>test.out
    rsh $line cat /home/basks.tbl|awk '{ print $1 }' >>test.out
    done

    The problem seems to be that script does not work !!! :-)

    Any ideas around using cat wiht the while loop in a better way ?

  2. Re: Scripting

    On Apr 22, 9:11*am, invincible wrote:
    > I am trying to read from a file for the list of servers and then
    > instruct the script to login on these servers and run a command to
    > check one text file.
    >
    > So far its done the below way...
    >
    > cat server-list | \
    > while read line
    > do
    > echo "------------------------------------------------" >>test.out
    > echo " HOST : $line" >>test.out
    > echo "________________________________________________" >>test.out
    > rsh $line cat /home/basks.tbl|awk '{ print $1 }' >>test.out
    > done
    >
    > The problem seems to be that script does not work !!! * :-)
    >
    > Any ideas around using cat wiht the while loop in a better way ?


    why recreate what is already provided to you?

    man dsh

  3. Re: Scripting

    >> man dsh
    dsh is part of csm (or pssp if you still run it) and not everyone has
    csm right ?

    >> The problem seems to be that script does not work !!! :-)


    Depends what your error is ..

    >> Any ideas around using cat wiht the while loop in a better way ?


    for host in $(cat server-list)
    do
    rsh ${host} "awk '{print $1}' /home/basks.tbl" >> test.out
    done

    Any good to you ?

    Rgds
    Mark Taylor




  4. Re: Scripting

    On Apr 22, 3:43 pm, Mark Taylor wrote:
    > >> man dsh

    >
    > dsh is part of csm (or pssp if you still run it) and not everyone has
    > csm right ?

    ....
    The dsh is provided from the csm.dsh package which is available since
    AIX 5.3 ( Maybe even AIX 5.2 ) and i believe its even installed by
    default.

    cheers
    Hajo


  5. Re: Scripting

    > The dsh is provided from the csm.dsh package which is available since
    > AIX 5.3 ( Maybe even AIX 5.2 ) and i believe its even installed by
    > default.
    >
    > cheers
    > Hajo


    But it will still need configuring even if the fileset is installed !

  6. Re: Scripting

    > But it will still need configuring even if the fileset is installed !

    and do we even know what level of code the OP is running was my
    point ...


  7. Re: Scripting

    On Apr 22, 4:33 pm, Mark Taylor wrote:
    > > But it will still need configuring even if the fileset is installed !

    >
    > and do we even know what level of code the OP is running was my
    > point ...


    It's AIX 5.3 ML4

  8. Re: Scripting

    invincible schrieb:
    > On Apr 22, 4:33 pm, Mark Taylor wrote:
    >>> But it will still need configuring even if the fileset is installed !

    >> and do we even know what level of code the OP is running was my
    >> point ...

    >
    > It's AIX 5.3 ML4

    But we still don't know what type or error you get.
    So all I can do is guessing. Maybe
    -n Specifies that the rsh command should not read from standard input.
    is the option you are missing. The rsh line then will be
    rsh $line -n cat /home/basks.tbl|awk '{ print $1 }' >>test.out

  9. Re: Scripting

    One thing that you should be aware of when using either dsh, or
    rsh is where your variables are getting interpreted, and where your
    commands are actually being run.

    For example, In your original example:

    rsh $line cat /home/basks.tbl|awk '{ print $1 }' >>test.out

    The cat is done on the remote node, the awk is done on the local node.
    The entire /home/basks.tbl is being sent across the network.

    What Mark had suggested is better, in a way...

    rsh ${host} "awk '{print $1}' /home/basks.tbl"

    The awk runs on the remote node, but the "$1" gets interpreted by
    the local shell, and is replaced with a blank. This would mean that
    the
    whole file would be returned.
    (To check the interpretations, use set -x and try the command
    individually)

    This would work better:
    rsh ${host} "awk '{print \$1}' /home/basks.tbl"

    Not understanding where the commands are being executed, and how the
    variables
    are interpreted will cause confusion about your data returned, but it
    won't cause
    the rsh to fail.

    So, as Thomas has hinted, more information about what is actually
    failing will probably
    give you more help on how to fix it.

    Hope this Helps
    --Casey

+ Reply to Thread