Database remote stop using shell script

Hi all

I need to close a remote database through shell script. I won't know SYS password and so cannot connect directly.
I need to SSH to the remote database will define ORACLE_SID and then stop the database.

Note Please I want to achieve this without calling any other SQL or shell script I have ssh.

Pointers or help is much appreciated.

Kind regards
Nagendra Chillale

Hi Nagendra,

following works for me...

SSH otherhost ".» \$home/.bash_profile
export ORACLE_SID = MYSID
echo \"shutdown abort\ | sqlplus------' / as sysdba\.
"

SSH otherhost ".» \$home/.bash_profile
export ORACLE_SID = MYSID
sqlplus------' / as sysdba\.<>
startup
EXPRESSIONS OF FOLKLORE
"

HTH Mathias

Published by: mzarick on August 13, 2009 11:27

Tags: Database

Similar Questions

  • How to write the CLOB parameter to a file or a XML using shell script?

    I run an oracle stored procedure using shell script. How can I get the OUT of the procedure (CLOB) parameter and write it to a file or a XML in UNIX environment using shell script?
    Edit/Delete Message
    SQL> var c clob
    SQL>
    SQL> begin
      2          select
      3                  DBMS_XMLGEN.getXML(
      4                          'select rownum, object_type, object_name from user_objects where rownum <= 5'
      5                  ) into :c
      6          from    dual;
      7  end;
      8  /
    
    PL/SQL procedure successfully completed.
    
    SQL>
    SQL> set long 999999
    SQL> set heading off
    SQL> set pages 0
    SQL> set feedback off
    SQL> set termout off
    SQL> set trimspool on
    // following in the script is not echo'ed to screen
    set echo off
    
    spool /tmp/x.xml
    select :c from dual;
    spool off
    
    SQL>
    SQL> --// file size
    SQL> !ls -l /tmp/x.xml
    -rw-rw-r-- 1 billy billy 583 2011-12-22 13:35 /tmp/x.xml
    
    SQL> --// file content
    SQL> !cat /tmp/x.xml
    
    
     
      1
      TABLE
      BONUS
     
     
      2
      PROCEDURE
      CLOSEREFCURSOR
     
     
      3
      TABLE
      DEPT
     
     
      4
      TABLE
      EMP
     
     
      5
      TABLE
      EMPTAB
     
    
    
    SQL> 
    
  • Coil PL/SQL parameter value using shell script

    Hello

    I execute PL/SQL procedure using shell script. I want the value of parameter in a coil OUTPUT text file. to_msg is the IN OUT parameter in the script below. Is this possible?

    sqlplus test/***@db < < EOFSQL
    COIL Status.txt
    HEAD off SET
    SET SERVEROUTPUT ON
    declare
    to_msg varchar2 (8000): = 'status ';
    EXEC P_Status (to_msg);
    SPOOL off
    "exit";
    EOFSQL

    AravindhK wrote:
    Thanks for your reply. When I roll the result, sql statements is also copied to the text file. How can I eliminate the sql statements.

    What are the results when you do as below

    sqlplus-s

  • How to connect to remote Oracle through shell script server.

    Hi, I'm new to Shell scripting. I try to connect to remote oracle system, but I think Sqlplus not found error. I have sqlplus executable inside bin under oracle home, but still, I get the same error. can someone guide me to get this thing done.

    export ORACLE_HOME=/opt/oracle/oracle11g/product/11.2.0
    export NLS_LANG = American_America.US7ASCII
    export LD_LIBRARY_PATH = $ORACLE_HOME/lib: $LD_LIBRARY_PATH
    Export ORACLE_PATH = $ORACLE_HOME/bin
    export PATH = $ORACLE_HOME/bin: $PATH

    sqlplus-s/nolog < < EOF
    connect wcadmin / [email protected]:1521 / wctest98
    Select * twice;
    output
    EXPRESSIONS OF FOLKLORE

    Please describe in more detail what you are doing. You run scripts 2 or is it in a script? If you set the variables of Oracle in a separate script, you need to run the script.

    Source to run a script, the commands in the script are executed as if you type to the current command prompt. A script that is not executed source will lose the variables that you define in the script when the script stops. You can source run a script using the '. '. " script" or "source" (bash). The export command adds variables to the environment of the executed orders later.

    See the following examples:

    cat > shelltest <
    
    Test1:
    $ a=a
    $ ./shelltest
    
    $ echo $a
    a
    
    Test2:
    $ export a=a
    $ ./shelltest
    a
    $ echo $a
    a
    
    Test3:
    $ . ./shelltest
    a
    $ echo $a
    b
    
  • Managed server starts do not using shell script

    Hi all

    I have configure weblogic server and 3 servers managed in it. I wrote a script to start the server. I am able to start the database/earpiece and weblogic admin server. But I'm not able to start managed server.script is as below. UCM_server1 does not start. When I click on 4, it's just showing

    From UCM_server1

    nohup: redirect stdout stderr

    .

    and so on

    I just also field path and all the numnber port

    Please suggest how to debug and fix this.

    « 2 »)

    Claire

    #

    lsnr_num ='ps - ef | grep tnslsnr | grep - v grep | AWK ' END {print NR} "

    If [$lsnr_num - gt 0]

    then echo "Database already running listener."

    else echo 'starting Infrastructure Database listener... »

    Starting from $ORACLE_HOME/bin/lsnrctl

    FI

    db_num ='ps - ef | grep pmon | grep - v grep | AWK ' END {print NR} "

    If [$db_num - gt 0]

    the echo then "database running."

    else echo ' from Oracle Database... »

    $ORACLE_HOME/bin/sqlplus "/ as sysdba" < < EOF

    #connect eu1/sys as sysdba

    startup

    EXPRESSIONS OF FOLKLORE

    #

    Sleep 10

    echo "Database Services started successfully."

    #

    FI

    ;;

    #---------------------------------------------------------------------------------------------

    « 3 »)

    ECHO "from WLS_Admin..."

    admin_num ='netstat - nl | grep '$ADMIN_PORT ' | grep - v grep | AWK ' {print NR} end "

    If [$admin_num - gt 0]

    then echo "WebLogic Admin Server running."

    else echo "."

    CD $DOMAIN_HOME/bin

    echo "start WebLogic Admin Server... »

    nohup./startWebLogic.sh > weblogic.out &

    sleep 5;

    admin_run ='grep-i 'Server started in OPERATION' weblogic.out | grep v - grep | AWK ' {print NR} end "

    While [$admin_run - eq 0]

    do

    sleep 5;

    admin_run ='grep-i 'Server started in OPERATION' weblogic.out | grep v - grep | AWK ' {print NR} end "

    fact

    FI

    ;;

    #---------------------------------------------------------------------------------------------

    « 4 »)

    ucm_num ='netstat - nl | grep '$UCM_PORT ' | grep - v grep | AWK ' {print NR} end "

    If [$ucm_num - gt 0]

    then echo "UCM_server1 already running."

    else echo "."

    CD $DOMAIN_HOME/bin

    ECHO "from UCM_server1... »

    nohup./startUCMDebugMemory1GB.sh UCM_server1 > ucm.out &

    sleep 5;

    ucm_run ='grep-i 'Server started in OPERATION' ucm.out | grep v - grep | AWK ' {print NR} end "

    While [$ucm_run - eq 0]

    do

    sleep 5;

    ucm_run ='grep-i 'Server started in OPERATION' ucm.out | grep v - grep | AWK ' {print NR} end "

    fact

    FI

    ;;

    best way to debug is to find the location of the log. Go to the location of the specified managed server and check out ucm_server.log. Check what error u get

  • Shell script to catch DB

    Hi all

    I have oracle DB in Amazon EC2. This DB will go down and I have to make every day.

    I want to write a shell script that checks the State of the DB and do.

    The things I do is

    Log in as root
    Su - oracle

    sqlplus
    user name:
    PWD:

    If DB is down, it shows error.

    So I'll do it again
    Log in as root
    . / stopPageview
    Su - oracle
    sqlplus
    user name: sys as sysdba
    PWD:

    the judgment
    startup

    output
    output
    . / startPageview

    How automatically using shell script?

    Published by: 969707 on January 9, 2013 04:36

    #! / bin/bash
    #
    # /etc/init.d/oracledb
    #
    # Startup script execution for the Oracle Listener and instance level
    # It relies on information on/etc/oratab

    # These are the paths for our basic installation
    export ORACLE_BASE = / opt/oracle
    export ORACLE_HOME=/opt/oracle/product/11.1.0/db_1
    Export ORACLE_OWNR = oracle
    export PATH = $PATH: $ORACLE_HOME/bin

    If [! f $ORACLE_HOME/bin/dbstart - o! d $ORACLE_HOME]
    then
    echo "Oracle startup: cannot start.
    Output 1
    FI

    case '$1' in
    implementation)
    # Start a listener and oracle instance
    echo - n "starting from Oracle:
    known $ORACLE_OWNR - c "start ORACLE_HOME/bin/lsnrctl $".
    known $ORACLE_OWNR-c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME.
    touch/var/lock/oracle
    echo 'OK '.
    ;;
    stop)
    # Stop listener and oracle instance
    echo - n "" shutdown Oracle: "."
    "judgment of $ORACLE_HOME/bin/lsnrctl" known $ORACLE_OWNR - c
    known $ORACLE_OWNR-c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME.
    RM-f/var/lock/oracle
    echo 'OK '.
    ;;
    reload | restart)
    $0 stop
    starting at $ 0
    ;;
    *)
    echo "use:" basename $0' start | stop | restart | reload. "
    Output 1
    ESAC

    Exit 0

    also use link below to create start & stop the database...
    http://www.Oracle-base.com/articles/Linux/automating-database-startup-and-shutdown-on-Linux.php
    http://www.exzilla.NET/docs/instance/StartupNshutdownWithshell.php

    *****************************************
    Best regards
    Shishir Tekade.
    My Blog: http://shishirtekade.blogspot.com

  • Shell Scripts installation / migration of an object

    Hi all

    We are on Oracle Applications R12 and we settle down with it. Our database servers and the app are under Linux. To migrate objects from one instance to another, or to install objects, we use two different approaches. One is to move objects manually using installation instructions (MD120) and the other using Shell scripts. We must now choose any of these two approaches. But we are not able to decide. Grateful if you can help me answer questions more. This will greatly help us to complete the process. I'm for the Shell Script. But if I'm good arguments / reasons, I am not against.

    1. who will be responsible for moving objects or migration? What DBA? If not, who? We DBAs perform this task.
    2. our DBAs have argument if they move using script, there will be a question of great control over what moves in database / application server. (Our DBA is no previous case management experience Oracle Applications. There used to be an Oracle DBA for Peoplesoft)
    3. If we have a few side by side comparison or a link to that will be perfect.
    4. If someone has a case study and / or best practices document from the industry on this issue, please share it with me. My email is [email protected].

    Earlier, I worked only in consultation of the companies where only the Shell script was the standard and best practices. It is my first company to the end user.

    Appreciate the help and thank you in advance.

    CAH

    Hello

    If you are willing to spend money, you could go with "Oracle Change Management Pack Application" as it can be used to migrate the changes / installation from one instance to another.

    Application Management Pack and Application Change Management Pack 3.1 now available
    http://blogs.Oracle.com/stevenChan/2010/01/amp_acmp_31_ebs.html

    Thank you
    Hussein

  • Exports (from shell script) without password given explicitly in the script

    Hi all
    I have Oracle 10g 2 on SLES 10 64-bit. I would like to export the database using shell scripts data pump. Is there a method to hide the password in the script file.

    Currently to be done by the command:

    expdp system/password@database...

    If any user who see the script will know the Passover.

    Concerning

    Groxy

    Hello

    Have you thought about the feature ' Secure external password store "which was added in 10 gr 2? It uses the Oracle Wallet to store a database_alias with the name of user and password credentials in an encrypted format. You can then enter your order expdp like this:

    expdp / @database_alias...

    Take a look at the security of 10gr 2 Guide. There is a chapter on how to put in place.

    John

  • Get the progress and result of a shell script

    Hello

    I would use a shell script to convert MP3 / audio FLAC files MP3 files with a bitrate of 192kbs and do other things in Automator or AppleScript script.

    So I installed lame and flac with brew, run an Automator process with a selected file and perform an action of AppleScrip:

    on run {input, parameters}
    
      if input is not {} then
    
      repeat with theFile in input
    
      set posix_file to POSIX path of theFile
    
      if input is not {} then
    
      tell application "Terminal"
    
      set thescript to "/usr/local/bin/lame -b 192 \"" & posix_file & "\" "
    
      do script thescript
    
      end tell
    
      end if
    
      end repeat
    
      end if
    
      return input
    
    end run
    

    The Terminal window is there because you tell the Terminal to run your script - try using shell script.

  • Query does not not in shell scripts

    Hi Experts,

    I created a query to check the temp tablespace use in production servers and I wanted to run the query using shell scripts, but when I run the query in the script I get no error or output I am unale to correct where exactly, I make the mistake

    This is the query

    SELECT A.tablespace_name 'space', D.gb_total, ROUND (SUM (A.used_blocks * D.block_size) / 1024 / 1024/1024,2) "gb_used", ROUND (D.gb_total - SUM (A.used_blocks * D.block_size) / 1024 / 1024/1024,2) 'gb_free' v$ \sort_segment A, (SELECT B.name, C.block_size, ROUND(SUM (C.bytes) / 1024 / 1024/1024,2) 'gb_total' v$ \tablespace B, v$ \tempfile C WHERE B.ts #= C.ts # GROUP BY B.name, C.block_size) D WHERE A.tablespace_name = D.name GROUP by A.tablespace_name D.gb_total

    You can help in this.

    Thank you...

    Basic Linux/Unix shell script format

    #! / bin/sh

    oracle set environment #.

    Export ORACLE_HOME =...

    export of SID =... or TWO_TASK = export

    .. etc.

    # launch sqlplus

    sqlplus-s/nolog<>

    Connect scott/tiger

    together... environment of sqlplus

    -execution of script sql (or sql query)

    @script.sql

    output

    EXPRESSIONS OF FOLKLORE

    #end script

    Character $ is interpreted by the shell as environment variables, you must escape the $ character is as well as it not assimilated to the variable approx.

    For example, v$ instance should be written as v$ instance.

  • export to shell script variable

    Hi all

    When I tried to export values of variables using shell script. Its exported values dies shell dies.
    oracle:/app/oracle # cat a.sh
    export ABC=hi
    oracle:/app/oracle # ./a.sh
    oracle:/app/oracle # echo $ABC
    ksh: ABC: parameter not set
    How to store these values in the current shell
    oracle:/app/oracle # cat a.sh
    export ABC=hi
    oracle:/app/oracle # . a.sh
    oracle:/app/oracle #  echo $ABC
    hi
    Problem I sthat, I can't use above method I provide parametrs to shell. I want to make the interactive script.

    select z in `ls`
     do
     echo $z
     break;
     done
     1) 1.txt
     2) a.sh
     3) admin
     #? 3
    admin
    Please suggest.

    Let me know if the issue is not clear.

    Thank you and best regards,
    Ajay

    How is it a question of Oracle? Have you tried to check the Unix Forum instead?

    Nicolas.

  • Using the shell script sql variable

    OS: Oracle Linux 5.10

    DB Oracle 11.2.0

    I have need to query the database and assign the return value to a variable of shell, but it does not work.

    create table imr_env (key varchar2(1000), value varchar2(1000) ;
    insert into imr_env values('TblspcUsagePct','90');
    commit;
    

    Here is the shell script:

    #!/bin/bash
    echo "in script"
    ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 ; export ORACLE_HOME
    ORACLE_SID=IMR1 ; export ORACLE_SID
    export PATH=$PATH:$ORACLE_HOME/bin
    
    pct=`sqlplus -S app/manager <<END
           set serveroutput on
           declare
              output_val number ;
           BEGIN
              select value into output_val from imr_env where key = 'TblspcUsagePct' ;
              dbms_output.put_line('output_val: ' || to_char(output_val)) ;
           END ;
           /
           exit;
    END`
    
    ## another sqlplus connection, use $pct in the where clause
    
    echo "var value is $pct"
    
    

    Here is the result:

    SQL> ./test.sh
    in script
    var value is 
    
    output_val: 90
    

    Why isn't the shell variable is populated with the value retrieved from the database?

    I need to use $pct in another query that will be storage spaces that are at least 90% full.

    I had to change to a korn shell - I couldn't get the "READ" command in shell or bash.

    But it is not only "READ" command:

    SQL > select * from IMR_ENV;

    THE KEY VALUE

    ------------------------- -----

    TblspcWarningLimit 90

    TblspcUsagePct 50

    SQL > exit

    Disconnected from the database to Oracle 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    With partitioning, OLAP, Data Mining and Real Application Testing options

    $ cat test.sh

    VAL = $(sqlplus-S test/test)<>

    Set feedback off

    set the position

    Select (value) from imr_env, including the key to_number = "TblspcUsagePct";

    Select (value) from imr_env, including the key to_number = "TblspcWarningLimit";

    "exit";

    EXPRESSIONS OF FOLKLORE

    )

    set $VAL

    Echo $1

    Echo $2

    $./test.sh

    50

    90

    $ echo $SHELL

    / bin/bash

    $

  • Stop the Service Console and shell scripts

    Now that VMware announced ESX 4.1 is their last hypervisor with a service console, I was wondering-

    What are the options to make what is now a large number of Linux shell scripts perform the same functions on ESXi - i.e. PowerCLI, Host Profiles, etc. and how long we have until officially support chips for the ESX service console?

    Thank you

    PowerCLI does not rely on a service console. However, you must have paid the ESXi version for them to work.  With respect to the profiles of the host, which is a characteristic of vCenter and has more no dependencies on the COS.  You can start watching to convert all of your shell scripts PowerCLI and use scripts.

    What about when VMware will stop support for ESX, I do not anticipate happening any time soon.

  • How to use select into command in shell script?

    I need to get the total number of rows in a table using select count (*) table and must assign a shell script variable. I used the following script, it returns the number of lines, but also with oracle headers, please help me to remove the headers.

    Shell script
    #! / bin/sh
    Count = "sqlplus $username/$password@$tnsname < < EOF"
    NEWPAGE 0 VALUE
    SET SPACE 0
    SET LINESIZE 80
    SET PAGESIZE 0
    SET ECHO OFF
    SET FEEDBACK OFF
    SET THE POSITION
    Select count (*) in the table.
    "exit";
    EXPRESSIONS OF FOLKLORE"
    echo "the value is"$count"


    O/P:

    SQL * more: Release 10.2.0.4.0 - Production on game Dec 22 05:01:33 2011 Copyright (c) 1982, 2007, Oracle. All rights reserved.
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64 bit Production with the partitioning, options Real Application Clusters, OLAP, Data Mining and Real Application Testing
    SQL > SQL > SQL > SQL > SQL > SQL > SQL > SQL 525935 SQL > >
    Disconnected from the database to Oracle 10 g Enterprise Edition Release 10.2.0.5.0 - 64-bit options of Production with the partitioning, Real Application Clusters, OLAP, Data Mining and Real Application Testing

    Use SQL * Plus silent mode. Change:

    Count = "sqlplus $username/$password@$tnsname<>

    TO

    Count ='sqlplus- s $username/$password@$tnsname<>

    SY.

  • import program does not process customized when you use the shell script

    Hello

    I have the pkg in that

    PROC1 without leaving param in this procedure, I call you created proc2 import and program

    Now, I call this proc1 in the shell script, here my flat program to import does not work

    Why? and I try to use CONSCUB on proc1 using 2 output param which is errbuf, retcode in the newspaper, I'm "wrong number of arguments"

    Please help me?

    Thank you

    Renon,

    Proc1 is your first program at the same time, right?

    How many parameters is defined for that?

    You can paste a screenshot of the window parameter?

    If there is no parameter, just use this:

    $FND_TOP/bin/CONCSUB $LOGIN SQLAP 'Accounts payable Manager' WAIT ' rajesh' = N SIMULTANEOUS SQLAP PROC1

    Assuming that "Renon" is a username of fnd and the program is set in the Application of accounts payable.

    See you soon

    AJ

Maybe you are looking for

  • Envy Notebook M6: M6 Notebook Envy will not install updates

    Hello My laptop will not install updates. He will get all the way to the end and then will say that he was unable to complete the updates. He then proceeds to uninstall and even repeats the process. I need help! Thank you!!

  • Toshiba virtual Store account Reset - 33709

    Please reset my Toshiba e-store account - 33709 Post edited by: dragon

  • Satellite M70 - suddenly no sound

    Hello! My son was watching a movie on my Satellite M70 the other night and just in the middle of it the stopped sound... second. He didn't touch anything (I was in the room with him when it happened) and there is no new parameters. So, I've updated a

  • send a return without success/failure message value

    Hello I talk TestComplete application using the COM adapter. I have a string value of test step to evaluate the return value and determine if it is pass or not (e.g. return 0 = pass, 1 = failure return).  This works perfectly. However, I have added a

  • Upgrade hard drive HP Pavilion Sleekbook 15 to SSD

    Hello I have a HP Pavilion Sleekbook 15 with the following product information, Product name: HP Pavillion Sleekbook PC 15 Product number: C6K58EA Will it be possible for me to upgrade my hard drive with an SSD? If so, what are the limits of the SSD