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.

Tags: Database

Similar Questions

  • How to automate the process of CopyApplication using the HFMCMD command line shell

    Hello

    Can someone please explain the automation application copy process using HFMCMD command line shell.

    Detailed information on the use of this are here (pg 19 of the referenced PDF):

    https://support.Oracle.com/epmos/faces/DocContentDisplay?ID=968956.1

    Command line shell

    New in 11 versions is a copy request utility that takes the input from the command line. This utility allows scheduling copy operations using third party, planning of utilities such as the built in Windows Scheduler. The HFM copy App Command Line Utility in releases of the + 11.1.2 lies in EPM_ORACLE_HOME\Products\ FinancialManagement \Utilities and for all the previous versions of + 11.1.1, the location is % Hyperion_Home%\FinancialManagement\Server. The utility is named HfmCopyAppCmd.exe or HfmCopyAppCmd_x64.exe.

    The command line utility has the same options that the utility based GUI with the exception being that there is no progress window to watch tasks participated and no option to retry a failed task. In order to run the command line utility, the computer that runs the utility must have installed the Package redistributable Microsoft Visual C++ 2005 SP1. This package is installed by the installer of version 11 EMP, so it doesn't have to be installed manually when executing an HFM application server, but it may be necessary to install the copy utility is run on a server database directly.

    Use: S = HfmCopyAppCmd.exe"" s = d ="" d =

  • How to use the MSG command

    Hi all

    I want to use the MSG command send message from my computer to other computers on a network. We work in windows 7 and I used the following syntax:

    MSG * / server IP: address 'Message '.

    but the message back to my computer even if I use the IP address of another computer

    Thank you

    Hi Michael,

    Advanced networking issues are supported in the TechNet Forums. I suggest you send the request in the TechNet forums.
    http://social.technet.Microsoft.com/forums/Windows/en-us/home?Forum=w7itpronetworking

    Hope this information helps.

  • 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
    
  • How to use the shutdown command to stop another computer?

    I just saw the setting-m to the shutdown command and decided to give it a whirl. However, when I pointed out the computer in question, I received a message that "a required privilege is not owned by the customer.

    What should I do to be able to use my laptop to turn off my old desktop computer? Both are running XP Professional SP3.
    Sometimes, I like reading or watching streaming video on Hulu on the laptop while lying in bed, and sometimes I play music if do the first, which is stored in the form of MP3 files on the desktop (which I access via a share). Be able to turn the office without getting up would be nice, but you do not get this option with Remote Desktop.

    Here is the result, the office is "slickswintel" (he's old, and since when I went first from Mac to Windows 98SE, although it is now a double XP/98) and the laptop is "slickslaptop".
    Both machines have unprivileged called 'Slick' on them local accounts that are my accounts on the day the main day. I have a different admin account, but I only use it as needed and use runas as often I log in fact.

    What should I do to get the following to work? In spite of the passing the MCSA Exam, I never learned about this feature, so I'm not sure what I should do to make it work? It'll work on a workgroup or is it only for domains? While I could set up a domain with the copy of the server I got from Dreamspark, I really didn't need one.

    Microsoft Windows XP [Version 5.1.2600]
    Copyright (C) 1985-2001 Microsoft Corp.

    D:\Documents and Settings\Slick > shutdown /?
    Usage: shutdown [-I |-l | s | r-|-a] [-f] [m \\computername] [t xx] [-c 'c
    COMMENT'] [d up: XX: YY]

    No args display this message (same as to-?)
    -i Display GUI interface, must be the first option
    l log off (cannot be used with the - m option)
    s shut down the computer
    r Shutdown and restart the computer
    -an abandonment, a system shutdown
    -m \\computername Remote to cancel the shutdown/restart computer /.
    t xx Set timeout for shutdown to xx seconds
    -c 'comment' comment (maximum of 127 characters) stop
    Forces f - running applications to close without war
    Ning
    d [u] [p]: xx:yy reason for closing code
    u is the user code
    p is a planned shutdown code
    XX is the main reason (the positive integer code
    SS to 256)
    YY is the minor reason (the positive integer code
    SS to 65536)

    D:\Documents and Settings\Slick > stop s m \\slickswintel
    The operation completed successfully.
    A required privilege is not held by the client.

    D:\Documents and Settings\Slick >

    As a general rule, you must have administrative privileges on the remote computer to shut down this computer.  Given that both computers have XP Pro, you are halfway there (remote users always authenticate as 'Guest' on XP Home).  The computer that you are trying to close must have "Simple file sharing" disabled because otherwise you can not authenticate to this computer as anything except the user "guest".  So try to disable Simple file sharing, make sure that your user name and password are the same on both computers and make sure you have administrative privileges on the remote computer, and then you can stop the machine with the command "shutdown".

    "How to disable the file sharing simple and how to set permissions on a shared folder in Windows XP"
      <>http://support.Microsoft.com/kb/307874 >

    In fact, it's easier to use the remote desktop.  Even if you do not have a "Shutdown" option in the start menu, you can always open a command prompt window (start-> Run-> "cmd") and enter the command:
    stop s f t 35
    This will give you 35 seconds to logoff this computer before its judgment (assuming that you have administrator privileges).

    You can also look in the command "psshutdown' of the PSTools Suite
    PSTools: <> http://technet.microsoft.com/en-us/sysinternals/bb896649 >

    HTH,
    JW

  • How to use the "Edit" command in Windows 7?

    HOW CAN I USE "EDIT" COMMAND IN WINDOWS 7
    THE DOSE OF CMD DOES NOT RECOGNIZE THE COMMAND EDIT

    Hello VICKY R,.

    Thanks for posting on the Microsoft answers Forum.

    Have you tried to do a right-click on the Cmd.exe and choose 'run as administrator '?
    Does that help?

    If this isn't the case, please provide more details, so we can help you.

    Thank you, Marilyn
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • How to use the chkdsk command in windows 7 its not working not not his poster error access denied

    Please help me about the chkdsk command to remove the windows command prompt 7...

    If you try to use chkdsk for C:\ partition, you cannot run that the disc must be disassembled for the operation, which is not possible with the C:\ partition (or the partition where Windows is installed).

    Instead, go on-> do work right click on the partition-> click Properties-> in the Properties dialog box, go to the Tools tab-> under error-checking, click check now... This will automatically set a check the next time you start Windows.
  • How to use the del command or any other to ignore files that it cannot remove (files in use) and continue to delete other files in a folder?

    I want to do a batch tha clean windows Temp folder. For this, I tried the del command, but the problem is to stop the deletion of files when it cannot remove a file in use. I want that he skip this file and continue to delete the other files too. I hope you guessed it. Please help me.

    Hello

    Thanks for posting your question in the Microsoft Community.

    The question you posted would be better suited in the MSDN Community.
    http://social.msdn.Microsoft.com/forums/en-us/categories

  • ORA-01403 while using SELECT INTO

    OK I have a strange problem. In my area of PL/SQL, I ran this code and it works fine.

    declare

    Val number (21);

    s_sql varchar2 (200);

    Start

    Select last_number in the Vale of all_sequences where sequence_owner = upper('TSS') and sequence_name = upper('ADDRESS_SEQ');

    Dbms_output.put_line ('val' |) Val);

    s_sql: = ' remove the TEST1 sequence. ADDRESS_SEQ';

    Dbms_output.put_line ('sql 2 ' | s_sql);

    s_sql: = ' create sequence TEST1. ADDRESS_SEQ minvalue maxvalue 1 999999999999999999999 begin by ' | Val | 'increment of 1';

    Dbms_output.put_line ('sql 3 ' | s_sql);

    end;

    However, when I write this procedure (which compiles fine BTW) I exception

    SET SERVEROUTPUT ON;

    create or replace procedure copy_sequence

    as

    Val number (21);

    s_sql varchar2 (200);

    Start

    Select last_number in the Vale of all_sequences where sequence_owner = upper('TSS') and sequence_name = upper('ADDRESS_SEQ');

    Dbms_output.put_line ('val' |) Val);

    s_sql: = ' remove the TEST1 sequence. ADDRESS_SEQ';

    Dbms_output.put_line ('sql 2 ' | s_sql);

    s_sql: = ' create sequence TEST1. ADDRESS_SEQ minvalue maxvalue 1 999999999999999999999 begin by ' | Val | 'increment of 1';

    Dbms_output.put_line ('sql 3 ' | s_sql);

    end;

    /

    exec copy_sequence();

    COPY_SEQUENCE compiled PROCEDURE

    Error from the 168 in the command line:

    exec copy_sequence()

    Error report:

    ORA-01403: no data found

    ORA-06512: at "SYSTEM. COPY_SEQUENCE', line 6

    ORA-06512: at line 1

    01403 00000 - "no data found".

    * Cause:

    * Action:

    That I captured:

    SET SERVEROUTPUT ON;

    create or replace procedure copy_sequence

    as

    Val number (21);

    s_sql varchar2 (200);

    Start

    Select last_number in the Vale of all_sequences where sequence_owner = upper('TSS') and sequence_name = upper('ADDRESS_SEQ');

    Dbms_output.put_line ('val' |) Val);

    s_sql: = ' remove the TEST1 sequence. ADDRESS_SEQ';

    Dbms_output.put_line ('sql 2 ' | s_sql);

    s_sql: = ' create sequence TEST1. ADDRESS_SEQ minvalue maxvalue 1 999999999999999999999 begin by ' | Val | 'increment of 1';

    Dbms_output.put_line ('sql 3 ' | s_sql);

    exception when TOO_MANY_ROWS then DBMS_OUTPUT.put_line ('too many authors in this State');

    When NO_DATA_FOUND then DBMS_OUTPUT.put_line ('NO_DATA_FOUND');

    While other then raise_application_error ("-20011," unknown Exception ");

    end;

    /

    exec copy_sequence();

    COPY_SEQUENCE compiled PROCEDURE

    anonymous block filled

    NO_DATA_FOUND

    No idea what is the problem?

    OK, here's the answer

    Procedure failed with ORA-01403, associated with immediate execution, captured

    It was related to the privileges given to the owner of the procedure. I gave then SELECT sequence and it worked

  • How to use the voice command?

    If you must go to the icon of voice control, you might as well just to make the call. Y at - it a shortcut?

    You can access the voice command by pressing the green call button.

  • How to use the password - AsSecureString in the script

    I would like to invite my script for the Active Directory User ID and password and use it more on in the connection-VIServers script

    something like...

    $MyAdUserID = Read-Host "enter a user name Active Directory"

    $MyAdPassword = Read-Host "enter password" - AsSecureString

    # now, I want to connect to a sequence of hosts vSphere5

    to connect-viserver < hostname > - the username-password $MyAdPassword $MyAdUserID

    It cannot authenticate with the SecureString password

    How to make it work?

    There is a conversion to use the password.

    The easiest way is to use the Credential parameter.

    $MyAdUserID = Read-Host "Enter Active Directory UserID" $MyAdPassword = Read-Host "Enter Password" -AsSecureString
    $cred = New-Object System.Management.Automation.PSCredential -ArgumentList $MyAdUserID,$MyAdPassword Connect-VIServer  -Credential $cred
    

    And take a look at the post of Arnim Bulk change your ESX root password, I think that's what you're looking for.

  • How to run the linux command line sql script

    Hi all!

    Just quick question. On my server I have to install the crontab script which will be eexecute some sql statements.
    How can I undergo command which will execute the script file without asking for password?


    sqlplus user/pass... and then what?


    Thank you

    dlugasx

    sqlplus user/pass @yourscript.sql

  • How to create a menu command in a script?

    I want to add a line or two at the end of a script.  I want to add is a menu command.

    I don't know if this can be done in jsx, and I wanted to ask here, that if it's possible, someone show me what that looks like, or point me to a reference on the web that covers?

    Thank you!

    He replied.

    var myMenuAction = app.menuActions.item("$ID/Name of Menu Item");

    If (myMenuAction! = null) {}

    myMenuAction.invoke ();

  • How to use analyze, control

    Hello friends,

    Hello. I hope that you all made great.

    I have a query that runs for a long time.

    I need to know the query using the COMMAND ANALZE statistics.

    Can someone tell me how to use the Analyze command with an example just for clairification.

    Thank you/Kumar

    Some information on the collection of statistics:

    http://www.Oracle.com/technetwork/database/focus-areas/bi-Datawarehousing/TWP-optimizer-stats-concepts-110711-1354477.PDF

  • Get PLSQL stored procedure in unix shell script

    Hi Experts,

    I have a PLsql procedure with the specification below-

    PROCEDURE SEND_INV_VIA_EMAIL (p_pdf_file_name IN VARCHAR2, p_submitted_frm IN VARCHAR2);

    I can pass two parameters of SHELL script and it works fine-

    # By calling the PLSQL procedure

    sqlplus-s $APPS_USER < < EOSQL

    SET SERVEROUTPUT SIZE 1000000

    whenever sqlerror exit 1;

    run MOB_XMLPUB_ARCHIVE_ARINV_PCK.send_inv_via_email ("basename $DATA_FILE", "ARCHIVE");

    "exit";

    EOSQL

    But now I want to have an output in the plsql procedure parameter-

    PROCEDURE SEND_INV_VIA_EMAIL (p_pdf_file_name IN VARCHAR2, p_submitted_frm IN VARCHAR2, p_return_status IN OUT VARCHAR2);

    based on this I want to determine the concurrent request completion status since the shell script is called via the simultaneous program.

    How will pass parameter out of the shell and how do I use this parameter in the SHELL script to determine completion status?

    Thank you very much.

    Vikrant

    Something like this:

    # By calling the PLSQL procedure
    sqlplus-s $APPS_USER<>
    SET SERVEROUTPUT SIZE 1000000
    whenever sqlerror exit 1;
    declare
    rstatus varchar2 (100) - or however long, it must be
    Start
    MOB_XMLPUB_ARCHIVE_ARINV_PCK.send_inv_via_email ("basename $DATA_FILE", 'ARCHIVE', rstatus);
    dbms_output.put_line (' status = ' | rstatus);
    end;
    /
    "exit";
    EOSQL
    grep 'Return status =' somefile

Maybe you are looking for