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

Similar Messages

  • 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?

  • 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

  • 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 ...

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • 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.

  • Passing variables to a shell script

    Hello all,
    I have an applescript that is passing two variables to a shell script. Both variables are being passed, but the script isn't running as I would expect and I can't figure out what it's doing and why.
    Here is the applescript:
    delay 5
    tell me to activate
    display dialog "Please enter the following information."
    property RoomNumber : ""
    display dialog "Enter the room number and building (ie 1312CAC):" default answer RoomNumber
    set the RoomNumber to text returned of the result
    property StationNumber : ""
    display dialog "Enter the Station Number:" default answer StationNumber
    set the StationNumber to text returned of the result
    do shell script ("echo " & RoomNumber & StationNumber & " | /Users/labadmin/Desktop/labbuild.sh")
    and here is the shell script
    #!/bin/sh
    RoomNumber="$1"
    StationNumber="$2"
    compname=($RoomNumber$StationNumber)
    scutil --set ComputerName $compname
    scutil --set LocalHostName $compname
    scutil --set HostName $compname
    echo "Done setting the computer name"
    The only name it sets is the ComputerName. LocalHost is blank and hostname is set to Localhost
    Can someone see what I'm doing wrong here?
    Thank you in advanced.

    The line
    do shell script ("echo " & RoomNumber & StationNumber & " | /Users/labadmin/Desktop/labbuild.sh")
    should be
    do shell script ("/Users/labadmin/Desktop/labbuild.sh " & quoted form of RoomNumber & " " & quoted form of StationNumber)
    In your original code, you are using echo to pass the variables to stdin of the script instead of as command-line parameters. You also don't handle the case where a value is left blank.

  • 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

  • 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 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

  • Parameter transfer to tmloadcf from Unix shell script.

    Hi.
    I am using Tuxedo global transaction with database password encryption, so I replaced by ***** the database password in OPENINFO string of the TMS in the UBBCONFIG GROUP section.
    As a result the password should be inserted manually when running tmloadcf.
    Do you know how this password can be inserted from a Unix shell scripts?
    I tried to use << or named pipe (mkfifo) but in both cases the tmloadcf remained stuck.
    Thanks in advance for your help.
    Amnon Katz.

    Amnon,
    The C library function isatty() is used to determine if tmloadcf is
    associated with a terminal. If isatty(0) returns 0, then the tmloadcf code
    to prompt for a password will fail.
    In some places in Tuxedo, there is functionality to allow reading a password
    from an environment variable if the process requiring the password is not
    associated with a terminal. However, this functionality is not available
    for tmloadcf. If you have an active Tuxedo maintenance contract and the
    functionalty of reading a database password from an environment variable
    when tmloadcf is not run from a terminal is important to you, you may want
    to file a support case and request that this functionality be added to
    tmloadcf. Otherwise, you will have to run tmloadcf from a terminal.
    Regards,
    Ed
    <Amnon Katz> wrote in message news:[email protected]..
    Thanks Ed for your reply.
    Do you know how tmloadcf identify that descriptor 0 is associated with a
    terminal?
    Is it possible to write some code that can emulates this situation?
    Regards,
    Amnon

  • Trouble in Unix calling a Java utility from another shell script

    Hi,
    I'm able to run a shell script (call it script B) in Unix which calls a Java utility. When I call script B from another script (script A) I get the error below. I have done much work to make sure the environment variables are the same.
    java.util.zip.ZipException: error in opening zip f
    ile
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:69)
    at com.something.runtime.ZipFileApplicationSource.<init>(ZipFileApplicationSource.java:22)
    at com.something.runtime.ZipFileRuntime.main(ZipFileRuntime.java:35
    ANY HELP WOULD BE GREATLY APPRECIATED.
    Thanks

    Here's my guess, if this doesn't work, post your scripts and maybe that will help.
    When you run your script B, you said it works. I think the problem is that when you run script B, your shell and envirenment variables are set by the window you're working in. When you call script B from script A, it creates a new shell to run it and it doesn't run the files that are run when you start a terminal or a telnet(it won't run .cshrc, .kshrc or .login). Depending on what OS you're using, I think the default shell is sh for most of them. The first line of script B should be
    #!/(your bin directory)/(shell you're using)
    for me it's
    #!/bin/tcsh
    then you might want to run your startup file to set envirenment variables, paths, etc...
    source (your user directory)/(the file name)
    for me it's
    source ~/.cshrc
    Then if you need to set the environment variables in your script.
    set CLASSPATH /usr/local/j2ee/bin.....
    set PATH /bin:/xyz....
    If that doesn't help post your scripts, or if I didn't explain it will enough, just ask.

  • 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

  • Bing "Map It" not showing up in any window accept when imputing a contact for the first time

    Bing's "Map It" function that is supposed to be present in office 2013 through emails is not... ive tried many different tests trying to input the addresses in different formats and there is no ability to get a map to the location. Maybe i am just mi

  • Max No. of columns returned in Query Template

    Hi All, Is there any limit to the max number of columns that can be returned for a sql query using the Query Template? Regards, Arijeet

  • Can I change my billing due date?

    Is there a way to change my billing due date to a different day of the month?  Having trouble finding any information and when I tried to call someone I was put through IVR hell.  Please advise.... thank you.

  • Change received name in Message

    In "Message", when I send a message to some one, it comes up as a shorten version of my name, so for example, "scooby" but my full name is scoobydoo. I would like to change it to my full name EG: scoobydoo. can any one tell me how to do this please?

  • Device Compatibility - Sony DCR TRV 355e

    Does anyone know if the Sony DCR TRV 355e is compatible with Final Cut Pro. A client has shot footage on this camera that he wants us to use but we don't have a Hi8 camera or deck so we are going to have to use his camera and connect via firewire. Th