I am trying to execute
sudo -su db2inst1 /opt/ibm/db2/V9.7/bin/db2 force application (1995)
but I get this error bash: syntax error near unexpected token
('`
sudo -su db2inst1 id
gives me correct output. So it must be something about the ()
If I try
sudo -su db2inst1 /opt/ibm/db2/V9.7/bin/db2 force application \(1995\)
I get
/bin/bash: -c: line 0: syntax error near unexpected token `('
/bin/bash: -c: line 0: `/opt/ibm/db2/V9.7/bin/db2 force application (1995)'
running /opt/ibm/db2/V9.7/bin/db2 force application (1995)
as db2inst1 user gives me the same error but running
/opt/ibm/db2/V9.7/bin/db2 "force application (1995)"
works fine
the right syntax is
sudo -su db2inst1 '/opt/ibm/db2/V9.7/bin/db2 "force application (1995)"'
Since you've got both the shell that you're typing into and the shell that sudo -s
runs, you need to quote or escape twice. (EDITED fixed quoting)
sudo -su db2inst1 '/opt/ibm/db2/V9.7/bin/db2 force application \(1995\)'
or
sudo -su db2inst1 /opt/ibm/db2/V9.7/bin/db2 force application \\\(1995\\\)
Out of curiosity, why do you need -s? Can't you just do this:
sudo -u db2inst1 /opt/ibm/db2/V9.7/bin/db2 force application \(1995\)
Try
sudo -su db2inst1 /opt/ibm/db2/V9.7/bin/db2 force application \(1995\)
Source: Stackoverflow.com