DavidHampson-rY

updated

14 years ago

DR

DavidHampson-rY

1 Rookie

•

294 Posts

0

7194

May 30th, 2012 09:00

nsradmin from command line

I need a little help with my syntax it seems!

I have a list of servers I am trying to gather some info from, however the script I am using does not seem to return any data (I am executing this from one line as I don't have rights to run shell scripts on our backup server!  However to make it clearer I have simply removed the ";" character which I put between lines):

cat /tmp/saphosts|while read -r hostname

do

     echo "show name;group;scheduled backup;schedule;save set\nprint type:NSR client;name:$hostname">/tmp/nsradminsap

     nsradmin -i /tmp/nsradminsap && rm /tmp/nsradminsap

     echo "----------------"

done

If I go into nsradmin and run the commands from the command line substituting $hostname for a known clientname it returns the data I would expect:

nsradmin> show name;group;scheduled backup;schedule;save set

nsradmin> print type:NSR client;name:xxx

                        name: xxx;

            scheduled backup: Enabled;

                    schedule: Full Monday;

                       group: FS_UX_PR_WY_MO_1930;

                    save set: All;

nsradmin>

Anyone able to suggest where I am going wrong!?

  • coganb

    736 Posts

    3268

    0

    Posted May 31st, 2012 00:00

    Hi David,

    I think your problem is that the newline isn't being created.  I tested it here and the \n didn't work which caused /tmp/nsradminsap to be all on one line which gives a blank from nsradmin.  I added a '-e' after the echo and it worked. 

    -Bobby

    bash-3.00# vi saphosts

    "saphosts" 14 lines, 206 characters

    while true

    do

         echo -e "show name;group;scheduled backup;schedule;save set\nprint type:NSR client;name:$1">/tmp/nsradminsap

         nsradmin -i /tmp/nsradminsap

         echo "----------------"

    done

    -----

    bash-3.00# ./saphosts vm-sol-27-109-12345

                            name: vm-sol-27-109-12345;

                scheduled backup: Enabled;

                        schedule: Default;

                           group: trace1;

                        save set: /etc/fonts;

                            name: vm-sol-27-109-12345;

                scheduled backup: Enabled;

                        schedule: Default;

                           group: Default;

                        save set: /Bobby;

    ...

  • DavidHampson-rY

    1 Rookie

    •

    294 Posts

    3268

    0

    Posted May 31st, 2012 02:00

    Thanks Bobby, that worked!

    regards

    David