0

I encounter a problem when launching a script using sudo, though I have no problem and the script works fine without sudo.

The Line is : mapfile -t dataList< <( tac /tmp/result.log | grep 'Command' | cut -d" " -f1 ) The error is "Syntax error near the unexpected symbol " < ". The sudo command is : sudo -u victor /tmp/parse.sh

Thank you all for help...

Encore
  • 91
  • 1
  • 5

1 Answers1

0

Sounds like a different shell is executing your script, one which doesn't understand the used syntax.

Your script /tmp/parse.sh might lack the #!/bin/bash (or similar) in its head line, and a different shell (root's login shell?) might be used to execute it.

This could be fixed by adding the missing #! line in the script header (recommended), or by calling the shell explicitly:

sudo -u victor bash /tmp/parse.sh
Alfe
  • 56,346
  • 20
  • 107
  • 159