Service id from a shell script

I'm attempting to pass a variable into a korn shell script in order to obtain a service_id, which we need to use for load balancing purposes.
JOB_STREAM_ID=20
sqlplus user/password@server <<EOF
var num_ number;
begin
select Service_ID
into   :num_
from   job_stream_service_mapping
where  Stream_ID = $JOB_STREAM_ID;
end;
exit :num_;
EOF
$ echo $?The following errors appear
SP2-0670: Internal number conversion failed
where  Stream_ID = ;
ERROR at line 5:
ORA-06550: line 5, column 21:
PL/SQL: ORA-00936: missing expressionObviously the $JOB_STREAM_ID variable is not being interpreted properly. I have also tried ${JOB_STREAM} and `$JOB_STREAM`. Not sure what the difference is to be honest!
Could any of you help out?
PS: I was unsure where to post this, so if I need to post this question elsewhere feel free to state which forum that might be.
thx
P;

I now get the following errors:
Stream_ID = $JOB_STREAM_ID;
PLS-00181: unsupported preprocessor directive '$JOB_STREAM_ID'
SQL> SP2-0670: Internal number conversion failedbased no the following script:
JOB_STREAM_ID=20
sqlplus apps/n3wsys@dolnsgc3 <<EOF
var num_ number;
begin
select Service_ID
into   :num_
from   job_stream_service_mapping
where  Stream_ID = \$JOB_STREAM_ID;
end;
exit :num_;
EOF

Similar Messages

  • Starting tomcat from a shell script

    Hello-
    I want to start Tomcat from a shell script that is called by an application on a web page. Problem is, the app that calls the script runs as user nobody.
    I'm a permissions noob, so any suggestions as to how I could get this working are appreciated.
    Will

    Tomcat should be running if you intend to use it as a service.
    You don't want people to be able to start (or.. stop !) services on your server from a web page... That would present a gaping security hole.

  • Calling a report from unix shell script

    Hi,
    I had to call a report from unix shell script.
    May i know the procedure to accomplish this
    Thanks in Advance
    A.Gopal

    First you should not include the whole path to your report in the call ...
    Use like this:
    /ora/u01/oracle/v101/as2/bin/rwrun.sh report=an_stati destype=file desname=/ora/u01/oracle/v101/as2/test.pdf desformat=pdf
    In $ORACLE_HOME/bin/reports.sh:
    1) Verify that you have updated the REPORTS_PATH variable to include your folder where you have the report in question
    REPORTS_PATH=/ora/u20/app/qits/env1/run:$ORACLE_HOME/reports/templates:$ORACLE_HOME/reports/samples/demo: ....
    2) Verify that the REPORTS_TMP variable is pointing to a valid location and that the oracle user has access to write on it.
    After that, post the content of the tracefile located at $ORACLE_HOME/reports/logs/{in-process report server name folder}/rwserver.trc
    If no file is present then it means that you need to enable trace in your reports's conf file.... go to the $ORACLE_HOME/reports/conf folder and and locate the .conf file that correspond to your in-process reports server name (as specified in the rwservelet.properties file)... open/edit the file to enable trace logs ..
    i.e.
    Change the following line:
    <!--trace traceOpts="trace_all"/-->
    to <trace traceOpts="trace_all"/>
    Bounce the reports server and try to run the report again, this time the .trc file should be generated, post the content so that we can take a look.

  • Calling stored procedure from unix shell script

    Hello,
    I am facing a problem while calling a stored procedure from UNIX shell script. I want to return a output variable from the stored procedure to the UNIX environment.
    Here is the code-
    #!/bin/sh
    OUTPUT=`sqlplus cmag/magnum@dw <<ENDOFSQL
    set serveroutput on;
    var prd_out varchar2(100);
    exec create_pm_window(:prd_out);
    exit;
    ENDOFSQL`
    echo " output is - $OUTPUT"
    The problem is :prd_out is not getting copied to shell variable OUTPUT.
    I have a dbms_output.put_line in the stored proc create_pm_window and I can see that prd_out is getting populated.
    Any help is really appreciated.
    Thanks'
    Rakhee

    First step :
    make sure the PL/SQL works as expected.
    Does the following display the expected output executed from SQL*Plus ?
    set serverout on
    declare
    prd_out varchar2(100);
    begin
    create_pm_window(prd_out);
    dbms_output.put_line('output is '||prd_out);
    end;
    I don't have your procedure, but using a dummy procedure like :
    Scott@my10g SQL>create procedure foo(p_out in out varchar2)   
      2  is
      3  begin
      4  select 'Hello '||instance_name into p_out from v$instance;
      5  end;
      6  /
    Procedure created. and a toto.sh script as :OUTPUT=`sqlplus -s scott/tiger <<EOF
    set pages 0 lines 120 trimout on trimspool on tab off echo off verify off feed off serverout on
    var mavar varchar2(100);
    exec foo(:mavar);
    print mavar;
    exit;
    EOF`
    echo "OUT = ${OUTPUT}"
    exitIt works fine :[oracle@Nicosa-oel ~]$ ./toto.sh
    OUT = Hello my10g

  • Passing Multiple Parameters to SQL Script from a Shell Script

    Hi Friends,
    I have SQL script which accepts 6 parameters.
    I am calling this from a shell script as shown below:
    sqlplus -s  ${ORACLE_ID} @${SQLPATH}KORONT_041.sql ${USER_ID} ${PDC} ${item_number} ${KORDC} ${PDCSET} ${last_Updated_in_hours} Out of the six parameters, item_number is not a mandatory parameter.
    When i pass all six parameters, there is no issue.
    But when i leave item_number blank, i am getting the below error
    Enter value for 6:
    User requested Interrupt or EOF detected.Based on the error, it seems that the NULL values for item_number is ignored and SQL*PLUS is waiting for one more input from user.
    How can i overcome this issue?
    Regards,
    Sreekanth

    Hi,
    I am calling the shell script from concurrent program and below is the log file of the concurrent program.
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    KORONT_041_SH module: KORONT - Daily Item Master Update
    +---------------------------------------------------------------------------+
    Current system time is 29-JUN-2011 10:09:35
    +---------------------------------------------------------------------------+
    REQUEST_ID: 68510795
    USER_ID: 4219
    PDC:    85
    Item Number:
    KORDC:    124
    PDCSET:   1100000003
    last_updated_in_hours: 24
    EMAIL_ID: [email protected],[email protected]
    SQLPATH: /e381/oracle/asodev01appl/custom/motont/1.0.0/sql/
    RPTDIR:  /e381/oracle/asodev01comn/admin/out/ASODEV01_asoprdb2
    RPTFILE: o68510795.out
    Table truncated.
    *Enter value for 6: User requested Interrupt or EOF detected.*
    Table truncated.
    old  15:       AND ic.organization_id   = &&4
    new  15:       AND ic.organization_id   = 1100000003
    0 rows created.
    Input truncated to 9 characters
    old   8:                AND organization_id   = &&4
    new   8:                AND organization_id   = 1100000003
    0 rows created.
    End of SQL
    No record.
    +---------------------------------------------------------------------------+
    Executing request completion options...
    +------------- 1) PRINT   -------------+
    Printing output file.
                   Request ID : 68510795      
             Number of copies : 0      
                      Printer : noprint
    +--------------------------------------+
    Finished executing request completion options.
    +---------------------------------------------------------------------------+
    Concurrent request completed successfully
    Current system time is 29-JUN-2011 10:09:38
    +---------------------------------------------------------------------------+Regards,
    Sreekanth

  • Is it possible to pass a variable from a shell script back to an Automator action?

    Is it possible to pass a variable from a shell script back to an Automator action?
    For instance, if I assign a value of foo to $var1 in my shell script how would I retrieve/pass that value in the next Automator action. I see that there is a variable called "Shell Script" but I can't any information on how to use it. 

    red_menace,
    Thanks but I still don't understand how to pass a single value that was set in the UNIX scipt back to Automator has a variable. Take the example below, I write 4 varables to STDOUT and all 4 are stored in a variable named "storage".  How do I assign 1 of these values to the Automator "storage" variable? For instance if I wanted to assign the value of $var2 to "storage" , how would I do that?

  • Error when running the OWB process flow from the shell script

    Hi,
    I am able to deploy the process flow succesfully but when I execute the process flow from the shell script,I am getting the following error.Previously it worked fine.
    I had to make some chnage in the IP address,so i had to deploy again.
    Connected.
    SQL> @/oracle/product/owb92028/owb/rtp/sql/oem_exec_template.sql OWB_RTR LOC_P_REL PROCESS P_W_SOURCE "," ","
    Elapsed: 00:00:00.00
    Elapsed: 00:00:00.01
    Stage 1: Decoding Parameters
    | location_name=LOC_P_REL
    | task_type=ProcessFlow
    | task_name=P_W_SOURCE
    Stage 2: Opening Task
    declare
    ERROR at line 1:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at "OWB_RTR.WB_RT_API_EXEC", line 17
    ORA-06512: at "OWB_RTR.WB_RT_API_EXEC", line 137
    ORA-06512: at "OWB_RTR.WB_RT_API_EXEC", line 164
    ORA-06512: at line 205
    Thanks in advance.
    Vinay

    Hi Kamal and kanakam kolla,
    This is just to let you know that,I solved my problem little differently by creating a new location and deployed the process flow.Now my process flow is working fine when i call from the shell script.What i see is that, it does not update properly when we update and redeploy the process flow.So far this is the work arround i could think off and i succesfully tested this.
    Thank you Kamal and kanakam kolla,for giving a thought towards my problem.
    Thanks
    Vinay

  • How to check from a shell script that a particular software is installed

    Hai friends
    I want to write a shell script which has to check whether a particular software is installed on the machine, or not. If installed, then what version is it using and the get the version number and which type of installer is it? i mean is it a .rpm installation or a tar.gz installation.
    how can i check this from a shell script. If any of you have any idea please give me a sample script to check this
    Thank you

    @Raja_Abilash
    I don't think this is a right thread & right forum to POST this question.
    better go ahead with forums related to LINUX.

  • Return codes from sqlldr command from unix shell script

    I am trying to capture error code from sql loader from unix shell script and display proper messages.
    sqlldr parfile=sdb.par control=$cntlfile data=$infile bad=$badFile log=$logFile rows=10000
    rows=10000
    retcode=`echo $?`
    case "$retcode" in
    0) echo "SQL*Loader execution successful" ;;
    1) echo "SQL*Loader execution exited with EX_FAIL, see logfile" ;;
    2) echo "SQL*Loader execution exited with EX_WARN, see logfile" ;;
    3) echo "SQL*Loader execution encountered a fatal error" ;;
    *) echo "unknown return code";;
    esac
    Eventhough, there are errors while executing sqlldr, it is always returing recode zero. What could be the possible reason
    Please advice

    Is there a typo in your code ?
    sqlldr parfile=sdb.par control=$cntlfile data=$infile bad=$badFile log=$logFile rows=10000
    rows=10000
    retcode=`echo $?` In this code, you get the return code of the statement in bold which is not the sqlldr statement ...

  • How to Reset dbid from a Shell Script

    I would like to use a shell script to:
    1) Automate the restore of our Produciton backups to a different server
    2) Reset the dbid prior to exiting the script
    Is there a way to reset the dbid from a shell script?
    When I use the following, it has an interactive prompt in the middle of it, and I don't see anything in the syntax diagram found in the "Oracle Database Utilities" manual that will let me get around this.
    nid target =/
    DBNEWID: Release 10.2.0.3.0 - Production on Fri Aug 8 09:37:04 2008
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to database DRTEST (DBID=3725550444)
    Connected to server version 10.2.0
    Control Files in database:
    /s01/oradata/drtest/control01.ctl
    /s01/oradata/drtest/control02.ctl
    /u01/oradata/drtest/control03.ctl
    Change database ID of database DRTEST? (Y/[N]) => y
    Proceeding with operation
    Changing database ID from 3725550444 to 3752603328
    Control File /s01/oradata/drtest/control01.ctl - modified
    Control File /s01/oradata/drtest/control02.ctl - modified
    Control File /u01/oradata/drtest/control03.ctl - modified
    Datafile /s01/oradata/drtest/system01.dbf - dbid changed
    Datafile /s01/oradata/drtest/undotbs01.dbf - dbid changed
    Datafile /s01/oradata/drtest/sysaux01.dbf - dbid changed
    Datafile /s01/oradata/drtest/users01.dbf - dbid changed
    Datafile /s01/oradata/drtest/rman.dbf - dbid changed
    Datafile /s01/oradata/drtest/temp01.dbf - dbid changed
    Control File /s01/oradata/drtest/control01.ctl - dbid changed
    Control File /s01/oradata/drtest/control02.ctl - dbid changed
    Control File /u01/oradata/drtest/control03.ctl - dbid changed
    Instance shut down
    Database ID for database DRTEST changed to 3752603328.
    All previous backups and archived redo logs for this database are unusable.
    Database has been shutdown, open database with RESETLOGS option.
    Succesfully changed database ID.
    DBNEWID - Completed succesfully.

    ... When I use the following, it has an interactive
    prompt in the middle of it, ...You may want to try out "Expect" for automating any interactive script.
    isotope

  • Debugging a program being called from a shell script

    hi All,
    i want to know how debug a C program being called from A Shell Script,
    my script looks like the following :
    ecReqProcMain $Cfg/ecReq.g $TotCnt 2>> $ErrFilei also have to pass some arguments to the script itsellft, which in trun going to pass it to the program,
    also in some cases i may be required to Pipe some data to the program, like the folowing
    cat DataFile | myProgramThanks ,

    You can also use ss_attach with the scheme that Anton
    suggested above. Instead of inserting "dbx" into your
    script, insert "ss_attach" into your script.
    It's also possible to change your script to something like this:
    cat DataFile | ${DEBUG} myProgram
    Then you can run your script like this:
    setenv DEBUG ss_attach
    ecReqProcMain $Cfg/ecReq.g $TotCnt 2>> $ErrFile
    --chris                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Reading variables from a shell script

    i was wondering if it is possible to enter variables from a shell script that an sql file can use:
    ex:
    shell script file
    #!/bin/ksh
    stty -echo
    read pwd?"Enter password for user: "
    echo
    stty echo
    read var?"Please enter value for variable: "
    echo
    $ORACLE_HOME/bin/sqlplus user/$pwd @TEST.sql
    sql file TEST.sql
    set serveroutput on
    set verify off
    spool out.log
    update table set parameter_value = '$var' where parameter_name = 'X';
    commit;
    exit;
    spool off;
    i tried that and it seems its updating my table with "var" and not what the user entered that is the bind variable $var
    am i missing something?

    if user hits enter (which means null) can the program
    not end and ask the user to enter another value?Try this way :
    while :
    do
            echo -n "Please enter value for variable: "
            read VAR
            if [ "$VAR" ]; then
                    break
            else
                    continue
            fi
    done

  • Web Service to call Power Shell Script

    Hello All,
    How can we make a call to power shell script from a asp.net web service with parameter ?
    Thanks in Advance

    Normally you can do everything using web service, why do you want to call powershell
    May be you can plan 
    http://geekswithblogs.net/Norgean/archive/2012/09/19/running-powershell-from-within-sharepoint.aspx
    Plan to use workflow for same
    http://ilovesharepoint.codeplex.com/wikipage?title=Execute%20PowerShell%20Script%20Action
    Also check 
    http://forums.iis.net/t/1161083.aspx?running+PS+scripts+from+a+webpage+sharepoint+site
    If this helped you resolve your issue, please mark it Answered

  • Launchd fails to execute a perl command from a shell script

    Hello all,
    i have a little script that runs rsync. I use perl to add a timestamp to each line of output. Basically it goes like this:
    #!/bin/bash
    rsync -avz $sourceFolder $destinationFolder 2>&1 | perl -e "while(<>){s/^/$(date "+%Y-%m-%d %H:%M:%S") [rsync_backup.daily] /g; print;}"
    Invoking this script from terminal works perfectly! Invoking it via launchd however fails. There is no error thrown, it just seems to not proceed.
    Any help is appreciated.
    Cheers.

    This is the output from the shell:
    /Users/sadmin/Library/rsync_backup
    uid=501(sadmin) gid=20(staff) groups=20(staff),501(com.apple.local.ard_admin),256(com.apple.access_vpn),403(c om.apple.sharepoint.group.2),204(_developer),100(_lpoperator),98(_lpadmin),81(_a ppserveradm),80(admin),79(_appserverusr),61(localaccounts),12(everyone),406(com. apple.sharepoint.group.5),502(com.apple.local.ard_reports),253(com.apple.access_ chat),252(com.apple.access_addressbook),401(com.apple.access_screensharing),504( com.apple.local.ard_manage),503(com.apple.local.ard_interact),250(com.apple.acce ss_afp),404(com.apple.sharepoint.group.3),500(com.apple.access_ssh),257(com.appl e.access_backup),254(com.apple.access_calendar),402(com.apple.sharepoint.group.1 ),255(com.apple.access_mail),251(com.apple.access_smb),405(com.apple.sharepoint. group.4),407(com.apple.sharepoint.group.6)
    de.open-service.rsync_backup.daily.sh
    0
    TERM_PROGRAM=Apple_Terminal
    SHELL=/bin/bash
    TERM=xterm-color
    TMPDIR=/var/folders/A5/A5M1umP6EsKqyAig3q3Bak+++TI/-Tmp-/
    Apple_PubSub_Socket_Render=/tmp/launch-VgtdY6/Render
    TERM_PROGRAM_VERSION=273.1
    USER=sadmin
    COMMAND_MODE=unix2003
    SSH_AUTH_SOCK=/tmp/launch-4Jjpml/Listeners
    __CF_USER_TEXT_ENCODING=0x1F5:0:3
    PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin :/usr/X11/bin
    PWD=/Users/sadmin/Library/rsync_backup
    LANG=de_DE.UTF-8
    HOME=/Users/sadmin
    SHLVL=2
    LOGNAME=sadmin
    DISPLAY=/tmp/launch-219jsQ/org.x:0
    _=/usr/bin/printenv
    rsync is /opt/local/bin/rsync
    perl is /usr/bin/perl
    This is the output via launchd:
    uid=501(sadmin) gid=20(staff) groups=20(staff),501(com.apple.local.ard_admin),256(com.apple.access_vpn),403(c om.apple.sharepoint.group.2),204(_developer),100(_lpoperator),98(_lpadmin),81(_a ppserveradm),80(admin),79(_appserverusr),61(localaccounts),12(everyone),406(com. apple.sharepoint.group.5),502(com.apple.local.ard_reports),253(com.apple.access_ chat),252(com.apple.access_addressbook),401(com.apple.access_screensharing),504( com.apple.local.ard_manage),503(com.apple.local.ard_interact),250(com.apple.acce ss_afp),404(com.apple.sharepoint.group.3),500(com.apple.access_ssh),257(com.appl e.access_backup),254(com.apple.access_calendar),402(com.apple.sharepoint.group.1 ),255(com.apple.access_mail),251(com.apple.access_smb),405(com.apple.sharepoint. group.4),407(com.apple.sharepoint.group.6)
    /Users/sadmin/Library/rsync_backup/de.open-service.rsync_backup.daily.sh
    0
    SHELL=/bin/bash
    TMPDIR=/var/folders/A5/A5M1umP6EsKqyAig3q3Bak+++TI/-Tmp-/
    USER=sadmin
    PATH=/usr/bin:/bin:/usr/sbin:/sbin
    PWD=/
    SHLVL=1
    HOME=/Users/sadmin
    LOGNAME=sadmin
    _=/usr/bin/printenv
    rsync is /usr/bin/rsync
    perl is /usr/bin/perl

  • Calling a report from a shell script

    We are modifying all concurrent programs to encrypt the oracle password by using the "ENCRYPT" option in the concurrent program definition for all unix based programs.
    The db user/password is derived from the FCP_LOGIN within the shell script. If I submit the concurrent prorgam and go to the root directory on which the unix shell scripts are present and execute the following command :
    ps -ef
    I can see the call to the concurrent program and since I am using the encrypt method, i cannot see the password(I could see the password before the change)
    The problem is one of the shell scripts is calling an Oracle Report by using ar25run command which needs a userid as the parameter.
    So when I issue the above ps command, i can see the password in the call to this report.
    Is there any other way of passing the oracle user/password to the report? This is required for SOX compliance.
    thanks,

    I guess it should be the same problem as if you are calling CONCSUB from unix also, because both need userid and password.
    If that's the case probably metalink note 104541.1 might help you.

Maybe you are looking for