Это команда, которую я хочу выполнить:
su - postgres -c "pg_dump ....."
для резервного копирования базы данных postgres.
Если я сейчас нахожусь в linux shell, как root, он отлично работает.
Но теперь я хочу запустить его из Java-приложения, как:
String cmd = "su - postgres -c \"pg_dump --port 5432 .....\""
Process p = Runtime.getRuntime().exec(cmd);
// read the error stream and input stream
p.waitFor();
Выдает ошибку:
su: unknown option "--port"
please try "su --help" to get more information
Теперь я изменяю код как:
Process p = Runtime.getRuntime().exec(new String[0]{cmd});
// read the error stream and input stream
p.waitFor();
Cannot run program "su - postgres -c \"pg_dump .....\"": java.io.IOException: error=2, no that file or directory
Что мне теперь делать?