0

I have a fairly long bash script. I want to run it with nice

nice ./test1.scr

if I do not run the script with nice, it works great. But when I run it with nice. commands being ran inside my script fail.

commandout=()
while IFS= read -r line # Read a line
do
    commandout+=("$line") # Append line to the array
done < <(tmsh show ltm pool $pool detail | grep -A5 "Ltm::Pool")
commandout+=(" ")

I get the following error if I run the script with nice

./test1.scr: line 269: syntax error near unexpected token `<'
./test1.scr: line 269: `                        done < <(tmsh show ltm pool $pool detail | grep -A5 "Ltm::Pool")'

if I don't run the script with nice everything works ok.

I want to nice the whole script so I can get reduce impact to other processes while this runs

Eugène Adell
  • 3,089
  • 2
  • 18
  • 34
Tony Haynes
  • 69
  • 1
  • 7
  • 3
    Does the `.scr` file start with `#!/bin/bash`? Otherwise it's possible that `nice` lauches it using `sh`. On many versions of Linux, `sh` is in fact `dash` and it doesn't know all the tricks `bash` knows. – axiac Aug 18 '17 at 23:18
  • You might want to use `readarray -t commandout < <(tush show ltm pool "$pool" detail | grep -A5 "Ltm::Pool")` instead. – chepner Aug 19 '17 at 01:17

1 Answers1

0

you didn't post as answer so I can't mark it as the answer. But OMG I am soooo freaking dumb.

The script started with #/bin/bash instead of #!/bin/bash that fixed it.

Tony Haynes
  • 69
  • 1
  • 7