I have this command which is being executed on a remote server. I tried to send it to a file on the server that is calling the ssh command but it doesn't look like it is working.

ssh $SERVER "su $ORACLE_USER -c 'export ORACLE_HOME=\"/u01/app/oracle/product/11.2.0\";
                                 export PATH=\"/u01/app/oracle/product/11.2.0/Opatch:\$PATH\";
                                 opatch lsiinventory'" > /tmp/output.txt

How can I get it working?

  • What happens if you move your last double quote to the very end to also contain the pipe to file command? – Kinnectus Jul 22 '16 at 19:47
  • That drops the file and output to the remote server. The output is there though. I would like to have it output to the server that is making the call. – John Jul 22 '16 at 20:04

If I place a () in the beginning and end of this it works.

(ssh $SERVER "su $ORACLE_USER -c 'export ORACLE_HOME=\"/u01/app/oracle/product/11.2.0\"; export PATH=\"/u01/app/oracle/product/11.2.0/Opatch:\$PATH\"; opatch lsiinventory'") > /tmp/output.txt

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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