Cannot proces shell variable

Hi All,
I am trying to write a BASH shell script, where I need to process the value of a database column. I am having trouble processing this value, and would like to know what your thoughts are. The part of the script I am having difficulty with has been isolated, and is presented below:
[oracle@oelvm03 bin]$ cat Problem.sh
#!/bin/bash
export ORACLE_SID=ORCL
export ORAENV_ASK=NO
export PATH=/usr/local/bin:$PATH
. oraenv
LOG_MODE=`sqlplus -s / as sysdba <<  EOF
set heading off
select log_mode from v\\$database;
exit;
EOF`
echo $LOG_MODE
case $LOG_MODE in
NOARCHIVELOG)
  echo In NOARCHIVELOG Mode.
ARCHIVELOG)
  echo In ARCHIVELOG mode.
MANUAL)
  echo Manual Archiving.
  echo Oops - Don\'t know what this mode is - ~$LOG_MODE~
esac
echo Finished!
[oracle@oelvm03 bin]$ Problem.sh
The Oracle base for ORACLE_HOME=/opt/oracle/app/oracle/product/11.2.0/dbhome_1 is /opt/oracle/app/oracle
ARCHIVELOG
Oops - Don't know what this mode is - ~ ARCHIVELOG~
Finished!
[oracle@oelvm03 bin]$The script is running on Oracle Enterprise Linux, against an Oracle 11gR2 database.
The problem is that the value of the LOG_MODE variable is not being processed correctly by the case statement. Examining the error message shows that there appears to be a leading space before the value
~ ARCHIVELOG~
I have tried desperately, in other scripts, to isolate the value and get the case to respond appropriately, but without any success.
Does anybody have any ideas on what I am doing wrong??

It will work in this case, but I would generally not use this approach. Please see below:
var="This v$log"
var=`echo $var`
echo $var
This vUsing "set pages 0 feed off" will not cause such problems and suppress control characters, feedback and other headers that you don't want when putting the output of a sql statement into a variable.

Similar Messages

  • How could I get unix shell variable value?

    I want to get a unix shell variable value because I will use it in my java program. For example $HOME, I have wrote like below,
    Runtime runtime = Runtime.getRuntime();
    Process proc = runtime.exec("echo $HOME");
    But I could not get $HOME value, just get "$HOME" as result.
    Why could not I get the value?

    Other than passing them as params to your program, the only way to read them runtime is either pipe them thru a stream or use JNI.

  • Get value from PL/SQL procedure to shell variable

    Hello,
    I have one little problem. I want to run plsql procedure from shell program and then I want to fill a shell variable with return value of plsql procedure or function. But I don't want to pass this value to some file and then read it.
    Thank's

    user9357436 wrote:
    Hello,
    I have one little problem. I want to run plsql procedure from shell program and then I want to fill a shell variable with return value of plsql procedure or function. But I don't want to pass this value to some file and then read it.
    Thank'sLike below?
    bcm@bcm-laptop:~$ cat day.sh
    set X
    var1=$1
    SQLPLUS="sqlplus -s"
    LOGON="user1/user1 "
    day=`$SQLPLUS $LOGON <<EOF
    set heading off
    set feedback off
    set verify off
    select 'Have a nice day!' from dual where dummy ='$var1';
    exit;
    EOF`
    echo $day
    bcm@bcm-laptop:~$ ./day.sh
    Have a nice day!
    bcm@bcm-laptop:~$

  • How to pass a shell variable to rman scripts

    I want to backup datafile to different directory
    depending on the current time,and I can do this to
    pass a shell variable to rman scripts,and this
    variable will used as part of format ,like this:
    backup incremental level=0
    tag rman_inc0_bck
    filesperset 5
    format '$(DIR)/rman_fulldb_%u_%s_%p_%d'
    (database include current controlfile)
    and $(DIR) is shell variable ,but rman will not
    recognize this ,how to achieve this?

    You could send your script to rman thru a pipe | or <<
    echo "backup incremental level=0
    tag rman_inc0_bck
    filesperset 5
    format '$(DIR)/rman_fulldb_%u_%s_%p_%d'
    (database include current controlfile);" | rman target /You could also create a "temp script" and then use it from rman with cmdfile
    sed "s,XXXDIR,$(DIR)," yourtemplate > /tmp/rmanscript.$$
    rman target / cmdfile /tmp/rmanscript.$$
    rm /tmp/rmanscript.$$

  • How to store multiline string literal in to java bean shell variable

    Hello Experts
    How to store multiline string literals in java bean shell like we use triple quote for jython variable
    Using Jython
    str=""" helllo
    welcome to my world"""
    above syntax is working but not for java bean shell like below
    String str=""" hello
    welcome to my world""";
    So how to do this in java bean shell. I came to this scenario while storing logs to a variable. I believe there is no solution for storing multiline strings to java bean shell variable.
    <@
    String str="<%=odiRef.getPrevStepLog("MESSAGE")%>";
    @>
    Any suggestion will be highly appreciated.
    Thank You.

    maddythehunk wrote:
    Im trying this but its not working...
    while(billingQueryParamsItr.hasNext()) {
         billingQueryParam = (BillingQueryParam) billingQueryParamsItr.next();
         System.out.println("****** Param Name-->"+billingQueryParam.getParamName());
         String[0] name = billingQueryParam.getParamName(); // giving error ; expected
         //billingItemActionForm.setParamName(billingQueryParam.getParamName());
    Declare the array outside of the loop. Fill the array as you iterate. And stop putting your error messages inside of comments in the code.

  • Issue with - "cannot find symbol - variable JOptionPane"

    need some help, got the below loop and want it to be able to loop by the number input by the input dialog. when i compile it i get an error in BlueJ. the error is "cannot find symbol - variable JOptionPane". Any help. have tried a few things however cannot get this to work at all. any suggestions?
    public void numberLoop()
    String qA = JOptionPane.showInputDialog(null,"How many times should this be completed (e.g. 1,2,3,4)?","Question",JOptionPane.QUESTION_MESSAGE);
    int qA2 = Integer.parseInt(qA);
    for (int startNum = 1; startNum <= qA2; startNum++)
    System.out.println(startNum + " squared is " + (startNum * startNum));
    }

    never mind i fixed it. forgot the below.
    import javax.swing.JOptionPane;
    LOL

  • How to use an UNIX shell variable in sql where clause

    Hi ,
    In my shell script first I get the Date and time from the system into the shell variable.At the end of the shell script I need to run a sql script in which I want to use the variable value in the where clause . Is there any way we can use a shell variable value in SQl script ?. Any help is greatly appriciated .
    Thanks in advance,
    Sampath

    Try the following
    In Unix
    SQLPLUS <username>/<password> @MyScript.sql <UNIX_Variable>
    In SQL*Plus
    Reference the variable as &1
    select *
    from MyTable
    where MyDate = to_date('&1','<date_format>');

  • E.getSource()         cannot find symbol - variable e

    I'm currently developing a program for course I'm in that needs to allow a user to open a file, scan the information out of it and display the results.
    I'm currently stuck on an error that's really confused me. On the line: if (e.getSource() == readButton) { 
    the compiler displays the following <cannot find symbol - variable e>.
    If anyone could advise me as to my mistake I'd be very happy.
       public void readData(){
        this.textArea.setText(""); // clear the text area, ready to append new strings.
        fc = new JFileChooser();
               File file = null;
               FileReader reader = null;
               if (e.getSource() == readButton) {
                int rValue = fc.showOpenDialog(Plotter.this);
                if (rValue == JFileChooser.APPROVE_OPTION) {
                    File file = fc.getSelectedFile();
                    reader = new FileReader(file);
                    log.append("Opening: " + file.getName() + "." + newline);
                else {
                    log.append("Open cancelled by user." + newline);
                log.setCaretPosition(log.getDocument().getLength());
                Scanner input = new Scanner(file);
                while (input.hasNextLine()){
             input.close();
        }

    scphan wrote:
    I guess you probably didn't see the post previous to yours ;). Just 2 minutes difference;Yes I did read that post. That is what prompted me to say I think they are doing it wrong. OP suggested that the readData method needed the ActionEvent to be passed as a parameter. Whereas I believe the actionPerformed method should be handle the event and the readData method should do just that: read data.
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == readButton) {
            readData();
    private void readData() {
        // method just reads the file
        // no need to handle event here
    }

  • The cannot find symbol - variable..... error

    i am recieving the "cannot find symbol variable getResident" error with the following line of code:
    if (Client.getResident=true)
    System.out.printf("Your Medicare Levy Contribution is: $%.2f %n", Client.getMedicare());
    i cant figure out why, maybe someone else may know and be able to help, i know that with int or double type methods u put parenthesis at the end of the method name, such as;
    while((Client.getGrossSalary())<=0)
    but i tried that here and it didnt change anything except the errror message.
    i have also tried putting parenthesis around the client.getResident, this didnt work either. i checked and made sure that the getResident method DOES in fact exist also.
    cheers for any help

    I have tried the following:
    if (Client.getResident()=true)
    if ((Client.getResident=true))
    if ((Client.getResident=(true)))
    if ((Client.getResident(true)))
    and none of these work, most of these alternatives return the error: unexpected type (Resident variable is boolean)

  • I am getting an error cannot resolve symbol variable?

    I am trying to run a PdfFormGenerator.java file and am using the iText API, hence have included
    the iText.jar file. When I compile the code I keep getting the following two errors:
    cannot resolve symbol variable CLASS_LOCATION
    cannot resolve symbol variable FORM_LOCATION
    can anyone guide me what I may have done wrong.
    Thanks,
    Zub

    Hi! To be more specific its these to line of the code is were I am going the errors:
        private String classLocation = Constants.CLASS_LOCATION;
        private String formLocation = Constants.FORM_LOCATION;Thanks

  • Read a Unix Shell Variable

    I need to write some code (i was told its only like 5 lines) that reads the value of a Unix Shell Variable. I searched the forums and found only 1 post on this subject:
    http://forum.java.sun.com/thread.jsp?forum=31&thread=397213
    I'm not sure if this is what i want to do however. my bosses co-worker, told me that i will need to use "System.properties" (i know there is no method System.properites but that is what he said) I looked into System.getProperites, and it just didn't make sence to me why i would be needing anything related to "System.properties". any suggestions on how to do this? (is it really only like 5 lines of code or is it much more complicated than that)
    Nick

    I did a google and found this immediately:
    http://www.javaworld.com/javaworld/javaqa/2001-07/01-qa-0706-env.html
    Google is your friend.
    It also returned a page expanding on the suggestion at the end of that article (using env), but rather than writing it to a file, using Runtime.exec to get an input stream and then sending that to java.util.Properties,
    which isn't a portable solution but doesn't require changing the invocation of the JVM.

  • Cannot determine shell type for PID 28704, UNKNOWN

    Hi All
    I am using ksh and executing a shell script, but it fails with following error
    Cannot determine shell type for PID 28704, UNKNOWN
    Please let me know if you have any solution for this
    Thanks
    Kanki

    Does the script do a ps -ef and grep for a PID, or does it look in a file for a /var/run/pid file? I would look at the script to see what it is looking for that is tied to the PID of 28704.
    You could also check to see that the script's first line has the correct shell defined.

  • [SOLVED]assigning "special" shell [variable] to awk, got problem

    $ VAR='AB' ; echo "$VAR" | awk -v foo="$VAR" '{gsub(foo,"Z");print}' # [1]
    Z
    $ VAR='[AB]' ; echo "$VAR" | awk -v foo="$VAR" '{gsub(foo,"Z");print}' # [2]
    [ZZ]
    $ VAR='[AB' ; echo "$VAR" | awk -v foo="$VAR" '{gsub(foo,"Z");print}' # [3]
    awk: (FILENAME=- FNR=1) fatal: Unmatched [ or [^: /[AB/
    $ VAR='AB]' ; echo "$VAR" | awk -v foo="$VAR" '{gsub(foo,"Z");print}' # [4]
    Z
    Just read about this:
    Regular Expression Operators @ The GAWK Manual wrote:
        This is called a character set. It matches any one of the characters that are enclosed in the square brackets. For example:
        [MVX]
        matches any of the characters `M', `V', or `X' in a string.
    And I tried,
    $ echo "[AB]" | awk '{gsub(/\[AB\]/,"Z");print}' #[5]
    Z
    $ echo "[AB]" | awk '{gsub(/[AB]/,"Z");print}' #[6]
    [ZZ]
    [2] is behaving like [6] when I actually want it to be acting like [5].
    What syntax should I use?
    Last edited by lolilolicon (2009-08-16 10:58:28)

    fumbles, I'm sorry I didn't explain myself clearly.
    $ VAR='[AB]' ; echo "$VAR" | awk -v foo="$VAR" '{gsub(foo,"Z");print}'
    outputs:
    [ZZ] --> awk replaces each of A and B with Z, and left '[]' intact.
    What I want is:
    Z --> awk treats '[AB]' as a whole normal input, just like 'ABCD' or whatever...
    Just like what I said, "[2] is behaving like [6] when I actually want it to be acting like [5]."
    I need to do this because I'm writing a script where shell variable is assigned to awk variable, which contains '[]'. Like you said, awk is treating it as part of a regular expression...
    EDIT:
    Ok, an ugly solution::
    $ VAR='[AB]'
    $ VAR=$(echo "$VAR" | sed 's/\[/\\\\\[/;s/\]/\\\\\]/') #now VAR='\\[AB\\]'
    $ echo "[AB]" | awk -v foo="$VAR" '{gsub(foo,"Z");print}'
    Z
    This almost sovles the problem I encountered in the script.
    But there should be a better answer!
    Say, is there a way to turn off awk's regular expression? --> Just found out grep's -F option. How about awk??
    Last edited by lolilolicon (2009-08-16 08:42:36)

  • Export shell variables into SPS variables

    I am looking for a way to assign shell variables which are defined in the "exec native" step, as a N1 variable.
    I will use this variable to generate a more userfriendly output in the "raise message"
    Has anyone an idea??
    Thanx

    Do you mean that you want to assign a value from within a shell variable to an N1 variable? If so, then you can use the <assignOutput> element in execNative. Here's an example:
    <varList>
    <var name="var1" default="not assigned"/>
    </varList>
    <simpleSteps>
    <execNative>
    <assignOutput varName="var1"/>
    <exec cmd="echo">
    <arg value="${my_shell_var}"/>
    </exec>
    </execNative>
    <raise message=":[var1]"/>
    </simpleSteps>
    ...

  • How to store jython variable to java bean shell variable

    Hello experts.
    I have one procedure. here is the details
    1st step is with java bean shell techonolgy and one variable.
    <@
    String testv=" ";
    @>
    Second step is jython technology.
    str3='storing some value as per my logic'
    <@testv@>=str3 // here I am getting error because i want to store jython variable to java bean shell variable
    Once it will be stored , I will use in query as SELECT '<@=testv@>' from dual. If this is not possible is there any way to get the jython variable in side refreshing query
    how to achieve this please suggest.
    Thank you.

    Hello experts. Any suggestion on this. How to store jython variable value into java bean shell variable.
    Thank You.

Maybe you are looking for

  • My first HP Mini 311 experience. (horror story)

    Service Order number: AQB780 - 01 Well this all started the 20th of April when I purchased a 311 from Ecost.com: http://www.ecost.com/Detail.aspx?edp=55 ... =155441519 I then received it on the 22nd, opened it up from the sealed HP box and upon first

  • Problem in BAPI_BUS2001_SET_STATUS

    Dear friends,       I have problem in BAPI_BUS2001_SET_STATUS. I am not able to set status of a project defination as REL which is created using BAPI_PROJECT_MAINTAIN. It is giving me the error message that project defination is not initial.

  • Query to find AP Invoices which are posted to GL

    Hi, I wanted to find the AP invoices which are posted to GL, any help with the query please? Thanks, Genoo

  • Branching from end of quiz slide

    I'm trying to branch from the end of quiz slide. The last quiz question will either send users to pass certificate for printing or Sorry, try again slide. When user prints certificate the published exe file doesn't know where to go next and goes to a

  • Adding nodes to cluster in 10g r2 10.1.0.3

    I apologize if this is a repeat but my browser crashed before I could watch my post. I am asking a hypothetical question regarding adding nodes to the cluster. I am trying to get a feel for how much risk is involved in the operation and if there is a