Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this line that I execute from php

sudo -u db2inst1 -s -- "/opt/ibm/db2/current/bin/db2 connect to PLC; /opt/ibm/db2/current/bin/db2 \"update EDU.contact set MOBILE_PHONE = '123'\""

it works fine on Sudo version 1.7.2.

Now I got new server with SUSE Linux Enterprise Server 11 (x86_64). There was no sudo so I installed it from repository (Sudo version 1.6.9p17) But know the above syntax doesn't work. It throws bin/bash: /opt/ibm/db2/current/bin/db2 connect to PLC; /opt/ibm/db2/current/bin/db2 "update EDU.contact set MOBILE_PHONE = '123'": No such file or directory

Any idea how I can make this work?

If I run /opt/ibm/db2/current/bin/db2 connect to PLC; /opt/ibm/db2/current/bin/db2 "update EDU.contact set MOBILE_PHONE = '123'" under db2inst1 account everythings work just fine.

share|improve this question
Would be nice to say why the down vote... – Radek Jul 11 '12 at 3:31
up vote 4 down vote accepted

I'm really not quite sure why you're getting this error. I have a system with sudo 1.8.3 on it, and the documentation clearly says something like sudo -s "echo hi" should work, but it doesn't.

The way I've always done this is to do the same thing -s [command] does, but manually.

sudo sh -c 'echo hi'

or in your case

sudo -u db2inst1 sh -c "/opt/ibm/db2/current/bin/db2 connect to PLC; /opt/ibm/db2/current/bin/db2 \"update EDU.contact set MOBILE_PHONE = '123'\""

Its more compatible as the -s argument hasn't always been around (and I unfortunately have some really old machines at work).

What's happening in the error you're getting is that it's looking for an executable which is literally named db2 "update EDU.contact set MOBILE_PHONE = '123'" in a directory called /opt/ibm/db2/current/bin/db2 connect to PLC; /opt/ibm/db2/current/bin (yes, it looks for db2 connect to PLC; as a directory). This obviously doesnt exist.

share|improve this answer
I really don't understand your explanation :-) better say I don't understand how this could happen. But your solution works nicely. Thank you. – Radek Jul 11 '12 at 5:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.