10

Can I convert this into 1 command line on bash in sqlplus? cause i want to automate it.

sqlplus / as sysdba
SQL> EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
exit
TheOneTeam
  • 25,806
  • 45
  • 116
  • 158
  • https://stackoverflow.com/questions/9462416/shell-one-line-query/31545856#31545856?newreg=27ff13f929b544a5b5cd908766f30769 try the upvoted method – Vishnu Krishnan Jun 27 '22 at 11:43

4 Answers4

16

You won't need the exit with automation because it should exit on end of file anyway. So on one line you could do:

echo 'EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);' | sqlplus / as sysdba
Sodved
  • 8,428
  • 2
  • 31
  • 43
  • Thanks. this would be the best answer as i don't want to create additional .sh or .sql at all – TheOneTeam Jun 28 '12 at 06:36
  • I try this command with select query but nothing happened. It just login and then disconnect. What should I do? – Mahfud Harun Aug 16 '13 at 01:41
  • Sounds like you're missing a `;` or `/` (on a line of its own) to actually run the command. Just a guess, you'll need to provide more details for a better answer – Sodved Aug 27 '13 at 05:55
6
sqlplus user/password@host @file.sql
Neerav
  • 1,399
  • 5
  • 15
  • 25
3

you can wirite by follow in a shell

#!/bin/bash
sqlplus / as sysdba <<EOF
EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
exit
EOF

or you can put this commond into a procedure

Jie Hou
  • 41
  • 4
0

sqlplus /nolog @your_script.sql

Iľja
  • 503
  • 4
  • 14