Su to another user from root doesn't work within shell script

Hello

I have a shell script that is run as root. Script rins ok until the point where it have to switch to user "mqm" to run other commands. It just hangs at the point of this line in the script

su - mqm -c "dspmq"

I ran the same commands at the terminal and they run fine.

Any thoughts.

Please show us the entire script (in CODE tags). And, show us (in CODE tags) how you invoke the script.

What operating system and shell are you using?

The behavior you are describing is frequently caused by mismatched quotes within a script or something else that we can't determine by seeing the line in the script where it becomes obvious that something has gone wrong.

Try

su mqm -c "dspmq"

instead.

1 Like

Thank you Vincent72. That worked.

Maybe mark this topic as solved ? :wink:

I tagged it as solved. Is that all its required??

1 Like

I guess so. Additionally there's a possibility to click on the "thanks" button but I'm not sure what purpose it serves.