Query v$ views from shell script fail

Hi everybody,
the query below is runing well with a SQL*PLUS (database is mounted and not open)
SQL> SELECT member FROM v$logfile;
MEMBER
+DATA/testgfi/onlinelog/group_1.298.773871647
+DATA/testgfi/onlinelog/group_2.294.773871647
+DATA/testgfi/onlinelog/group_3.295.773871647
But Giving error if I run it from Shell script ???
$ sqlplus -s '/ as sysdba' << EOF
SELECT member FROM v$logfile;
EOFSELECT member FROM v
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only..
Please help..
Thanks..
Aljaro

Aljaro wrote:
Hi everybody,
the query below is runing well with a SQL*PLUS (database is mounted and not open)
SQL> SELECT member FROM v$logfile;
MEMBER
+DATA/testgfi/onlinelog/group_1.298.773871647
+DATA/testgfi/onlinelog/group_2.294.773871647
+DATA/testgfi/onlinelog/group_3.295.773871647
But Giving error if I run it from Shell script ???
$ sqlplus -s '/ as sysdba' << EOF
SELECT member FROM v$logfile;
modify as below
SELECT member FROM v\$logfile;

Similar Messages

  • Intermittent "Power Shell Script failed to run" after installing SQL MP 6.5.4.0

    We recently installed the SQL MP.  One thing I am struggling with is this "Power Shell Script failed to run" that occasionally comes up, but, not always on the same server, and not always at the same time. 
    It says it ran past the configured timeout of 300 seconds. 
    The post that seemed to have me on the right track was
    https://social.technet.microsoft.com/Forums/en-US/c539a55d-dd48-438f-b7d5-06ed2cecf6e9/powershell-script-failed-to-run-alerts-from-sql-management-pack-6410?forum=operationsmanagergeneral
    However, even after getting one of the several scripts that have been generating the error, out of the extract management pack, it has parameters that need to be fed to it that I have no idea what they are....
    Example.  ActiveRequestsDataSource.ps1 requires $computername, $connectionstring, $tcpport, $sql_wmi_namespace, and $servicename. 
    The computername is easy enough...  so is tcpport.  but, the others... not so much. 
    I am fairly certain I will be able to run these manually, if I just knew the parameters...  I am also fairly certain we are getting these because at the time of the check, resources on that server are tied up for one reason or another. 
    Can someone please help?  This is killing me. 

    Hi,
    As this issue happens after you installing SQL MP, so from my point of view, it seems like caused by the runas account for the SQL MP is not configured well, I would like to suggest you follow the article below to configure runas account for the management
    pack:
    Configuring Run As Accounts and Profiles in OpsMgr – A SQL Management Pack Example
    http://blogs.technet.com/b/kevinholman/archive/2010/09/08/configuring-run-as-accounts-and-profiles-in-r2-a-sql-management-pack-example.aspx
    Regards,
    Yan Li
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Problem while calling concsub from shell script

    Hi All,
    I am facing problem when I am trying to run CONCSUB utility from shell script.The same works well when I try it from command line.The only prob I am facing from shell script is assigning values to temporary variables.
    This is how my script looks
    #!/bin/bash
    export PARM5="$5"
    export PARM6="$6"
    export PARM7="$7"
    echo "INTPARM5=\"$PARM5\""
    echo "INTPARM6=\"$PARM6\""
    echo "INTPARM7=\"$PARM7\""
    echo $FND_TOP/bin/CONCSUB $1 ONT 'Order Management Super User, Vision Operations (USA)' $3 WAIT=Y CONCURRENT ONT $PROGRAM "$INTPARM5" "$INTPARM6" "$INTPARM7"When I try to run the above shell based concurrent program it doesn't pass the parameters as expected and it errors out saying "Wrong number of arguments to call the procedure"
    I tried my luck from some of the previous posts ({thread:id=2360776} ),but to vain
    If anyone has any ideas,please suggest!!
    Thanks in advance!!
    Edited by: sandy on May 4, 2013 12:54 PM

    Here are your proofs
    Proocedure
       PROCEDURE abc(--p_errbuf            OUT   VARCHAR2,
                                                --p_errcode           OUT   VARCHAR2,
                                 p_order_no          IN    NUMBER DEFAULT NULL,
                                                p_customer_id       IN    NUMBER DEFAULT NULL,
                                 p_name              IN    VARCHAR2 DEFAULT NULL
          IS
                    v_cname    VARCHAR2(200);
               v_ordered_date DATE;
               v_order_number  NUMBER;
              v_order_type    VARCHAR2(200);
    BEGIN
                fnd_file.put_line(fnd_file.output, 'Begin Execution');
       SELECT DISTINCT ac.customer_name,
                    d.ordered_date ordered_date,
                    d.order_number order_number,
                    x.NAME order_type
            INTO   v_cname
               ,v_ordered_date
               ,v_order_number
               ,v_order_type
               FROM oe_order_headers_all d,
                    oe_transaction_types_tl x,
                    wsh_delivery_details b,
                    wsh_delivery_assignments c
                    ,ar_customers ac
              WHERE 1 = 1
                AND ac.customer_id = b.customer_id
                AND d.order_type_id = x.transaction_type_id
                AND x.LANGUAGE = 'US'
                AND b.released_status = 'B'
                AND b.source_header_id = d.header_id
                AND c.delivery_detail_id = b.delivery_detail_id
                AND d.order_number=NVL(p_order_no,d.order_number)
                AND ac.customer_id = NVL(p_customer_id,ac.customer_id)
             AND x.name=NVL(p_name,x.name)
                AND NOT EXISTS (SELECT 1
                                FROM wsh_delivery_details b
                               WHERE 1 = 1
                                      AND b.released_status != 'B'
                                      AND b.source_header_id = d.header_id)
                                       --BETWEEN ('1213794') and ('1213797'))
                AND rownum<2;
            INSERT INTO xxc_temp(customer_name,ordered_date,order_number,order_type) VALUES(v_cname,v_ordered_date,v_order_number,v_order_type);
            COMMIT;
             fnd_file.put_line(fnd_file.output, 'Order Number is' || v_order_number);
             fnd_file.put_line(fnd_file.output, 'Order Type is'   || v_order_type);
       END;Script
    #!/bin/bash
    set -x
    export PARM5="$5" 
    export PARM6="$6"
    export PARM7="$7"
    sqlplus -s $1 <<EOF
    set head off feed off serverout on size 1000000
    exec abc('$PARM5','$PARM6','$PARM7');
    exit
    EOFNow when I run the 'XX Order Detail CSV Report' I get the below log and no Output
    +---------------------------------------------------------------------------+
    Application Object Library: Version : 12.0.0
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    XXKES_PDF_TRANSFER module: XX Order Detail CSV Report
    +---------------------------------------------------------------------------+
    Current system time is 06-MAY-2013 05:05:56
    +---------------------------------------------------------------------------+
    + export PARM5=66432
    + PARM5=66432
    + export PARM6=
    + PARM6=
    + export PARM7=Mixed
    + PARM7=Mixed
    + sqlplus -s APPS/APPS
    +---------------------------------------------------------------------------+
    Executing request completion options...
    Output file size:
    0
    +------------- 1) PRINT   -------------+
    Disabling requested Output Post Processing.  Nothing to process.  The output of the request is zero byte.
    +--------------------------------------+
    Finished executing request completion options.
    +---------------------------------------------------------------------------+
    Concurrent request completed successfully
    Current system time is 06-MAY-2013 05:05:56
    +---------------------------------------------------------------------------+After the concurrent program executed I queried the table xxc_temp and here you see the data
    SQL> select * from xxc_temp;
    CUSTOMER_NAME
    ORDERED_D ORDER_NUMBER ORDER_TYPE
    A. C. Networks
    18-FEB-13        66432 MixedMy procedure fetches the data fro given set of i/p parameters but it doesn't give o/p coz it's a host based conc program.Please advise if there's a way to get the o/p in a host based conc program
    Thanks!!

  • Urgent Problem in Executing perl script from shell script

    Hello,
    I've a shell script on one server (source) and a perl script on another (target).
    My perl script will check whether the directoryname, filename provided by shell script exists on the target server or not.
    My shell script is as follows:
    #! bin/bash
    cmd=`ssh user@target "perl /home/user/test_dir/validate_file.pl"`
    echo $cmd
    And my perl script uses a package CU_Functions.pm, which is in the same directory as the perl script on the target server.
    But when I invoke the perl script from shell script, I get the following error:
    Source:user> (db:ias10g12_mid_db) /home/user/perl
    $ sh /home/user/arcs/arcs_conn.sh
    user@target's password:
    Can't locate CU_Functions.pm in @INC (@INC contains: /local/perl-5.6.1/lib/5.6.1/i686-linux /local/perl-5.6.1/lib/5.6.1 /local/perl-5.6.1/lib/site_perl/5.6.1/i686-linux /local/perl-5.6.1/lib/site_perl/5.6.1 /local/perl-5.6.1/lib/site_perl .) at /home/user/test_dir/validate_file.pl line 13.
    BEGIN failed--compilation aborted at /home/user/test_dir/validate_file.pl line 13.
    Please let me know if I need to do any configurations prior to call the perl script.

    As for the Perl INC, I cannot recall the environment variable that sets that but the following example should work:
    ssh user@host "export ENV_VAR=/path/to/include/files:$ENV_VAR ; /full/path/to/script"

  • Please help to call oracle procedure with out paramter from shell script

    Hi
    I want to call a process with out parameter from shell script. I am calling process in shell script in below way
    function Process_loads {
    ( echo 'set serveroutput on size 1000000 arraysize 1'
    echo "set pagesize 0 term on verify off feedback off echo off"
    echo "BEGIN"
    echo " dbms_output.put_line('Before Calling The package'); "
    echo " x ( '$1', '$2', '$2', '$4', '$5', '$error_code'); "
    echo " dbms_output.put_line('After Calling The package'); "
    echo "EXCEPTION "
    echo " WHEN OTHERS THEN "
    echo " dbms_output.put_line('BIN_LOAD_ERROR' || SQLERRM); "
    echo " ROLLBACK;"
    echo "END;"
    echo "/" ) | sqlplus -s $USER/$PASSWORD@$SID
    Here $error_code is out paramter. All varaibles passed in process are declared with export command.
    When executing .sh it gives below error
    "sh ERROR at line 3: ORA-06550: line 3, column 99: PLS-00363: expression '' cannot be used as an assignment target ORA-06550: line 3, column 3: PL/SQL: Statement ignored".
    Please help to get rid from this error or please suggest how to call a oracle procedure with out paramter from unix shell script.
    Thanks in advance

    You can try this:
    From sql*plus
    SQL> ed
      1  create or replace procedure my_proc(p_id in int, p_result out int)
      2  as
      3  begin
      4  select 10 * p_id
      5  into p_result
      6  from dual;
      7* end my_proc;
    SQL> /
    Procedure created.
    SQL> set serveroutput on
    SQL> declare
      2  v_r int;
      3  begin
      4  my_proc(10,v_r);
      5  dbms_output.put_line(v_r);
      6  end;
      7  /
    100
    PL/SQL procedure successfully completed.
    from bash:
    testproc.sh:
    #!/bin/bash
    (echo 'set serveroutput on';
    echo 'declare';
    echo 'v_r int;';
    echo 'begin';
    echo 'my_proc(10,v_r);';
    echo 'dbms_output.put_line(v_r);'
    echo 'end;';
    echo '/';) | sqlplus -s u1/u1
    Console:
    oracle@mob-ubuntu:~$ chmod u+x testproc.sh
    oracle@mob-ubuntu:~$ ./testproc.sh
    100
    PL/SQL procedure successfully completed.With kind regards
    Krystian Zieja

  • Passing parameters from shell script to OWB process flow

    Hi all,
    I am running OWB process flow (using the template script provided by oracle) and i want to pass two date parameters as shown below:
    sqlplus -s $SQL_USER/$SQL_PWD@$ORACLE_SID @$HOME_DIR/src/vmc_oem_exec_script.sql OWB_OWNER VMC_POST_DW_PF_LOC_SIT PROCESS VMC_NM1_PORT_MAIN "," "P_DATE_FROM=$DATE_FROM,P_DATE_TO=$DATE_TO"
    How do i catch those values in process flow and pass those to mappings in Process flow?
    Do i need to create PF variables with same names or any name will do?
    Thanks in advance

    This document is explaining how to pass data between activities in process flow.
    I am passing parameters from a shell script.
    Any ideas,how to pass parameters from shell script and then initialize the process flow variables based on those values and then pass them further to mappings.
    Thanks

  • Accept input from Shell script in sql*plus

    Hey! Guys..
    i need the following info.
    I am running a shell script from sql*plus. I need to accept a value from shell script into my .sql file.
    thanks..
    Harsh.

    prompt for input, pass to another shell
    # contract_status_prompt.sh
    read udate?"Enter week-ending date in format dd-mmm-yyyy: "
    contract_status_update.sh $udate >$FDWLOG/current/contractstatusupdate`date +%d%h%y`.log
    echo `date`
    # End contract_status_prompt.sh
    Read the variable passed and use in SQLPlus:
    # contract_status_update.sh
    echo "Running contract_status.sh"
    echo "create records for contract_status"
    echo `date`
    echo " "
    echo " date used is "; print $1
    echo " "
    sqlplus <<exit
    @$FDWSQL/sqlparms
    set time on
    prompt *** Set contract_status_period ***
    update contract_status_period
    set period_date = '$1';
    commit;
    exit
    etc.

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

    Hi All,
    I have Oracle 10g2 on SLES 10 64-bit. I would like to do export the database using data pump from shell scripts. Is there any method to hide the password in the script file.
    Currently in doing by command:
    expdp system/password@database ....
    So any user who see the script will know the passowrd.
    Regards
    Groxy

    Hi,
    Have you considered the "Secure External Password Store" feature that was added in 10gR2? It uses the Oracle Wallet to store a database_alias with username/password credentials in encrypted format. Then you can enter your expdp command like this:
    expdp /@database_alias ...
    Take a look at the 10gR2 Security Guide. There's a chapter there on how to set this up.
    John

  • Calling a java code from shell script.

    Hi all,
    I want to access a method of java class from a unix shell script.basiacally I want to know how to access a java code from a shell scriptt.If anybody has any info on this , kindly revert back to me.
    Rgds,
    Satya

    Hi,
    Suppose I hv a main() method.
    Then how to access that class from Shell Script.
    Can u send me the piece os compiling and running process for it.
    Rgds,
    Satya

  • Calling sql script from shell script

    Hi,
    I know this question has been asked many time in various forums, but I tried many combinations and not able to figure out what I'm missing.
    Basically - I'm trying to call a sql script from a shell script.
    This is my sql script (plsql.sql) -
    DELCARE
    v_empno NUMBER := '&empno';
    BEGIN
    select ename,sal from emp where empno = v_empno;
    dbms_output.put_line('Inside the plsql file');
    END;
    This is my unix shell script - I'm caling the plsql.sql file with the parameter passed(97882). I don't get any output. at least I should be able to view the dbms output if not for the sql query inside the sql script.
    #!/usr/bin/ksh
    sqlplus -s sam/olo01 << HERE
    @plsql.sql 97882;
    HERE
    What is it I am missing ?

    Using your scripts (and having to create and populate a table myself, that would have what your select statement implies),
    oracle:oklacity$ cat plsql.sql
    DELCARE
    v_empno NUMBER := '&empno';
    BEGIN
    select ename,sal from emp where empno = v_empno;
    dbms_output.put_line('Inside the plsql file');
    END;
    oracle:oklacity$ cat doit.sh
    #!/usr/bin/ksh
    sqlplus -s sam/olo01 << HERE
    @plsql.sql 97882;
    HERE
    oracle:oklacity$ ./doit.sh
    SP2-0042: unknown command "DELCARE" - rest of line ignored.
    SP2-0734: unknown command beginning "v_empno NU..." - rest of line ignored.
    oracle:oklacity$
    This is the kind of information you should have put in your opening post.

  • Calling pl/sql stored procedure from shell script ( kshell)

    hello.,
    i have written a stored procedure. i need to call this stored procedure from a unix shell script ( korn shell).
    can anyone please help me how can i do it.actually there are 3 stored procedures. so my shell script has to call each stored procedure, execute it then go to next stored procedure execute it.
    if by chance inbetween any stored procedure do not execute then the shell script has to tell me that this stored procedure failed to execute.
    please help me in this.
    thanks
    madan

    Sorry Madan,
    Following is the complete solutiion:
    !# /usr/bin/ksh
    sqlplus -s user/pass@server << EOF > a.log
    exec proc1;
    exec proc2;
    exec proc3;EOF
    if [ $? -eq 0 ]
    then
            echo "\n Procedures completed successfully at `date`"
    else
            echo "!!! FAILED!!!"
            echo "Details can be found in a.log File"
    fi

  • Query not running in shell scripting

    Hi Experts,
    I have created a query to check the temp tablespace usage in production servers and i wanted to run the query using shell scripting but when i running the query in the script i am not getting any errors or output i am unale to rectify where exactly i am doing mistake
    below is the query
    SELECT A.tablespace_name "tablespace", 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" FROM v$\sort_segment A, (SELECT B.name, C.block_size, ROUND(SUM (C.bytes) / 1024 / 1024/1024,2) "gb_total" FROM 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
    Please help out in this.
    Thanks....

    two files:
    1) file to connect, for example called conection.sql
    ../../../sqlplus user/password@your_database @../../../../your_script.sql
    2) your script in the other file "your_script.sql"
    SELECT A.tablespace_name "tablespace", 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" FROM v$\sort_segment A, (SELECT B.name, C.block_size, ROUND(SUM (C.bytes) / 1024 / 1024/1024,2) "gb_total" FROM 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;
    3) execute --> conection.sql

  • Calling sqlplus from shell script

    Hi ,
    I am calling sqlplus from a shell script. After running sql commands successfully, it fails to continue executing commands from the shell script.
    There is no EXIT statement at the end of the sql.
    The error i get is,
    SP2-0734: unknown command beginning "echo "FFFF..." - rest of line ignored.
    Can someone please help.

    how does your shell script looks like? did you check my other post today on this forum
    sqlplus called from a shell script

  • Passing parameters to query called through a shell script

    I have a file called getInfo.sql that contains a query like:
    spool ./myInfo.txt
    select *
    from myTable
    where col1 = '&val1'
    and col2 = '&val2';
    spool off
    I would like to call SQLPLUS from a shell script and pass this file in as a parameter. How would I pass in the values for
    &val1 and &val2 ?
    Any help would be appreciated.
    Thanks
    Rajan

    Yes, you put a line in the script that looks like this:java classname parameter1 parameter2 parameter3 ...Then the JVM will call the static main(String[] args) method of "classname" and put those parameters into the "args" array.
    If you are asking how to generate such a script, or how to call it from your COBOL program, sorry, I don't know how to do that.

  • Error in calling SQL plus program with parameter from Shell script

    This is my Shell script. I am trying to call in the SQL plus program with the parameter and the shell script is registered as a concurrent program.
    PARAMETERS=`echo $1 |tr -d '\"'`
    DB_USER_ID=`echo $PARAMETERS|cut -d" " -f3|cut -d"=" -f2`
    CONN_STRING=$DB_USER_ID
    REQ_DATE=`echo $PARAMETERS|cut -d" " -f9|cut -d"=" -f2`
    timestamp=`date +%m-%d-%y-%H:%M:%S-%Z`
    timestam=`date +%y-%m-%d`
    sqlplus -s $CONN_STRING @ar_statement.sql $REQ_DATE
    chmod 755 statement.sh
    . statement.sh
    My Sql plus program is like this.
    set pagesize 0
    set heading off
    set feedback off
    spool $GEC_TOP/log/ge_ar_statement.sh
    select output_file_name
    from fnd_concurrent_requests
    where trunc(actual_completion_date) = '&2';
    spool off;
    exit;
    When i run the concurrent program, i am getting the following error:
    ar_statement: line 14: REQ_DATE: command not found
    Enter value for 2:
    User requested Interrupt or EOF detected.
    ar_statement.sh: line 1: Enter: command not found
    ar_statement.sh: line 2: User: command not found
    ar_statement
    Program exited with status 127
    I am not strong at Unix Porgamming and i would request someone who can
    help me out as soon as possible.
    I need this solution quickly and thank everyone in advance.
    Thanks.

    Can you put your coding between code statements, like shown in the FAQ. It will be easier to read.
    Looking at your script, my first guess is that crontab will not find your sqlplus since your script does not have $HOME/bin in the $PATH. From what I understand, running .profile in your script will not work either because variables are exported to sub-shells, not to the shell above. You can call your script with a dot like . ./script which means that the script will run like it was typed at the command prompt. But it will be less confusing to define appropriate variables in the script. eg.
    ORACLE_SID=my_instance_name
    ORACLE_HOME=/my_path_to_oracle_home_directory
    LD_LIBRARY_PATH=$ORACLE_HOME/lib
    PATH=$ORACLE_HOME/bin:$PATH
    I remember some slightly different way of coding to handle the sqlplus return codes.
    For instance:
    sqlplus -s /nolog > /dev/null <<-EOF
    connect system/manager
    @ssm.sql
    whenever oserror exit failure
    whenever sqlerror exit failure
    EOF
    sql_err=$?
    if [ $sql_err -ne 0 ]; then
       echo "FAILURE"
    else
       echo "SUCCESS"
    fiThe - in -EOF supresses tab's
    Using connect will prevent ps from showing your login credentials
    In some versions of bash the ending EOF needs to be at the beginning of the line to work.
    Edited by: waldorfm on Jul 14, 2010 7:05 PM
    complaining about putting code between code delimiters and forgot myself ;-)
    Edited by: waldorfm on Jul 14, 2010 7:08 PM
    Btw, if you "source" a script running it like . .script, than an exit in that script will log you out.

Maybe you are looking for

  • My iPhone won't allow me to download IOS 5

    When I download IOS 5, a message appears and says, iPhone will not take IOS 5. When I try to update my apps, it says that the apps are not compatible on this devise...?

  • How can i get my apps back?

    I had a 4th generation ipod touch that i bought apps on through the app store, but it broke so i bought another but now i cant figure out how to get the apps back. I tried going to the app store, then to purchased (using the same account) but in the

  • RMI, WebServices... Which one is better?

    Hi! I am not new in Java programming but I am new in the filed of Web Services and XML data management. I am developing a client-server application (with secure conecctions) and I want to use XML to manage the information sent and received between th

  • Zen Micro shutting down on its

    No biggie but my Zen Micro plays 3 or 4 songs then shuts down on its own. The battery is always fully charged and the interface is locked by sliding the top button over until the "lock" icon appears on the screen. Am I doing somethig wrong or is my p

  • Why is this on my account?

    I understand some may wish to use this, so if I wanted to I would have set it up myself. However, I discovered recently that Skype to Go was set up automatically, just because I added my mobile to my profile. As this was done without my consent, I am