Search code examples
linuxsshsu

Executing db2 command through ssh


trying to ssh to another system then perform db2 commands however using 'su db2admin -c' does not seem to work, although it works for normal system commands ..

#!/bin/bash

sshpass -p 'passw0rd' ssh root@server.com "su db2admin -c 'db2text start'"

this is the output ..

rob@laptop:~/Desktop$ ./script.sh
bash: db2text: command not found

Any ideas?


Solution

  • The PATH is not getting updated to the normal root users PATH. Either specify the full path to db2text or add a dash (-) before the username to reload the environment variables