1

im actually working with a small script, this script uses a comand from a NAS EMC Storage, the main idea is to storage and output variable and use it for other command.

nameserver="$(nas_server -list -all | awk 'NR == 3 {print $6}')"


serverparam1="$(server_param "$nameserver" -facility NDMP -list)"

echo "$serverparam1" 

So.. this command nas_server -list -all | awk 'NR == 3 {print $6} returns "server_3"

the idea is to storage the name "server_3" and use it in this other command:

server_param server_3 -facility NDMP -list

The problem with all this stuff, is that the output print is not "server_3" only get "ver_3" i don't know why this is happening.

This is the ouput of the terminal:

[nasadmin@xxxx ~]$ ./test.sh
 : ver_3
 : unknown hostver_3

This is the output from server_param

    [nasadmin@xxxx ~]$ server_param server_3 -facility NDMP -list
server_3 :
param_name                       facility  default     current   configured
maxProtocolVersion                  NDMP          4          4
scsiReserve                         NDMP          0          0
DHSMPassthrough                     NDMP          0          0
CDBFsinfoBufSizeInKB                NDMP       1024       1024
noxlt                               NDMP          0          0
bufsz                               NDMP        128        128
convDialect                         NDMP     8859-1     8859-1
concurrentDataStreams               NDMP          4          4
includeCkptFs                       NDMP          1          1
md5                                 NDMP          1          1
snapTimeout                         NDMP          5          5
dialect                             NDMP
forceRecursiveForNonDAR             NDMP          0          0
excludeSvtlFs                       NDMP          1          1
tapeSilveringStr                    NDMP         ts         ts
portRange                           NDMP 1024-65535 1024-65535
snapsure                            NDMP          0          0
v4OldTapeCompatible                 NDMP          1          1

    [nasadmin@xxxx ~]$ nas_server -list -all
id      type  acl  slot groupID  state  name
1        1    0     2              0    server_2
2        4    0     3              0    server_3

id       acl  server    mountedfs       rootfs  name
1        0    1         17              13      TEST_VDM-1
2        0    1         16              14      TEST_VDM-2

Thanks

A.lacorazza
  • 117
  • 1
  • 2
  • 8
  • 1
    What do you get if you hex-dump it? `./test.sh | xxd` – melpomene Sep 05 '17 at 17:42
  • 3
    Sounds like `\r` somewhere in the output – choroba Sep 05 '17 at 17:46
  • Actually, make that `./test.sh 2>&1 | xxd`. We want to get stderr, too. – melpomene Sep 05 '17 at 17:48
  • Can you show us the output of `nas_server -list -all`? – Jack Sep 05 '17 at 17:53
  • I could not reproduce your problem on a similar EMC NAS (VG2). Also the output of `server_param movername -facility NDMP -list` is a formatted table. Could you post the complete `test.sh` script? And also explain what info are you trying to get at the end. – Dima Chubarov Sep 05 '17 at 17:53
  • As @choroba suggested, your input file contains trailing control-Ms. Run dos2unix or similar on it before running your command. – Ed Morton Sep 05 '17 at 18:00
  • @DmitriChubarov it's a EMC VNX. – A.lacorazza Sep 05 '17 at 18:15
  • @EdMorton could you show me some example of what you propouse? or a link ? – A.lacorazza Sep 05 '17 at 18:19
  • @Jack done, updated the main question. – A.lacorazza Sep 05 '17 at 18:20
  • 1
    Just search for `dos2unix` in the archives of this site or google it. You'll find thousands of hits, pick any one. The issue is your input lines end in `string\r\n` instead of just `string\n` and `\r` causes the cursor to jump back to the start of the line when you print it so you get some output then the cursor jumps back thanks to the `\r` and then you get the rest, overwriting what was already printed. Pipe the output of your command to `| cat -v` to see the `\r`s as `^M`s. – Ed Morton Sep 05 '17 at 18:20
  • Need the output of `nas_server`, not `server_param`. – Jack Sep 05 '17 at 18:27
  • @Jack lol, done. – A.lacorazza Sep 05 '17 at 18:30
  • I'm inclined to agree with the others about the `\r` lurking in the output of `nas_server`. If your installation does not have `dos2unix`, you can use `tr -d '\r'` instead. Put that in the pipeline before `awk` and see what happens. – Jack Sep 05 '17 at 18:42

1 Answers1

1

This worked for me

nameserver="$(nas_server -list -all  |  awk 'NR == 5 {print $6}')"

nameserver1="$(dos2unix $nameserver)"

serverparam0="$(server_param "$nameserver0" -facility NDMP -list)"

echo "$serverparam0"
A.lacorazza
  • 117
  • 1
  • 2
  • 8