Sample shell script - to run procedures and shell script

Hi ,
I would like run some procedures in one shell script which passing parameters as username/password@dbname.
1. Execute proce1
2.Execute proce3
3.Execute proc4
Can you please give some script/idea how we will create shell script . I am using SunSolaris Unix operating system.I would appreciate your help.
Regards,
Clark

user10818198 wrote:
I would like run some procedures in one shell script which passing parameters as username/password@dbname.
1. Execute proce1
2.Execute proce3
3.Execute proc4
At a very basic level, based on the information you have provided, your shell script would be something like this:
sqlplus /nolog <<EOF
connect username/password@dbname
exec proce1;
exec proce2;
exec proce3;
exit
EOFBesides this, you could:
(1) Add the shebang at the top, to specify the shell you are using, e.g. #!/bin/ksh for the Korn shell etc.
(2) Ensure that "sqlplus" is recognized by the shell, by maybe running an "ora_env.sh" script that sets Oracle parameters. More likely, if you are using this Unix account for interaction with Oracle, then you may want to add the Oracle parameter information in your .profile or .bash_profile or .csh_profile etc. in the home directory.
(3) Run a few sqlplus commands right before calling those stored procedures, if needed. For example, if you want to exit from sqlplus (and Oracle) if an error occurs while executing any procedure, then add this -
whenever sqlerror exit 1Thus your script becomes:
#!/bin/ksh
# Ensure that Oracle parameters are set by this point
sqlplus /nolog <<EOF
connect username/password@dbname
whenever sqlerror exit 1
exec proce1;
exec proce2;
exec proce3;
exit
EOF(There are other settings as well; it really depends on your requirements.)
Can you please give some script/idea how we will create shell script . I am using SunSolaris Unix operating system.
How to create a shell script ? Well,
(1) Save the commands shown above in a file, using your favorite text editor. Name the file "my_script.sh" or "<a_better_name>.sh" etc. (or maybe ".ksh" for the Korn shell - it's just a best practice, the shell doesn't really care.)
(2) Make your script executable, like so -
$ chmod 744 myscript.sh(3) And then execute it -
$ ./myscript.sh- You could also execute the script in the current shell (as against a child shell) by doing this after Step (1):
$ . myscript.shHope that helps.
If there are specific questions, then post them here.
isotope

Similar Messages

  • I get this error message quite frequently:: (TypeError: attempt to run compile-and-go script on a cleared scope) what does it mean and how do I stop it?

    I get this error message quite frequently:: (TypeError: attempt to run compile-and-go script on a cleared scope) what does it mean and how do I stop it? It doesn't happen always but it is often.

    Ever since the 6.0.2 update - every single day there's been something new going horribly wrong. For the past couples weeks it has been the browser hanging or crashing for no apparent reason and now this error hitting the browser screen over and over a hundred times a minute. I've used firefox since it began and NEVER had any issues previously. This 6.0 upgrade is a downgrade and is making me seriously look at Chrome (never IE - why I switched to firefox), though making the switch will be a pain due to all the apps I rely on and thousands of bookmarks that would need to be transported. Please mozilla fix this because using this browser has suddenly gone from seamless to frustrating pretty much overnight!

  • Column link in interactive report to run procedure and refresh

    I have an interactive report which displays a report based on a table. This is a summary table populated overnight from some complex spatial analysis, which takes a few hours to run. I have a requirement to allow the user to refresh one row in this table - they would do this during the day if they needed to see the most up-to-date values.
    I have a package with two stored procedures - one which does the full refresh of the table, and one which refreshes one row when PK is passed in.
    One of the columns in the table is 'last_refreshed' which is a date - this is shown in the interactive report including minutes.
    I was thinking that maybe I could include a hyperlink on this 'last_refreshed' date column in the report. When a user clicked on it, it would run the stored procedure for that row and would refresh the report.
    Any ideas on how I could do this? I've hit a bit of a dead end for now.
    Thanks

    OK, I worked it out.
    I created an application item to store a global variable.
    Then in the column attributes of the report, I set the 'last_refreshed' to be a linked column, setting target to the current page and then setting the application item global variable to be the row PK.
    Then I have a Process which runs the required stored procedure reading the application item global variable, set to run on page load.
    Sorted.

  • Mount script for ext2 - mixing applescript and shell script

    Hello
    i want to do a .app using the ScriptEditor to get my external usb-disc mounted.
    I tried ExtFS Manager before, but was not as happy with it.
    so the basic idea is some kind of mixture of apple script and bash-shell script, but im not sure how to combine it.
    shell script:
    #!/bin/sh
    sudo kextload /Library/Extensions/ext2fs.kext
    mkdir ~/usb_music/
    sudo mount -t ext2 -o nosuid,w,m=777,user /dev/disk1s5 ~/usb_music/
    sudo chmod a+rwx ~/usb_music/
    apple-script:
    on run
    try
    do shell script ""
    end try
    end run
    any ideas how to get it combined and working ?
    best regards
    fidel
    MacBookPro 15,4" 1,83 GHz   Mac OS X (10.4.8)  

    is there a way to implement it in a way that normal users can work with sudo to mount the drive ?
    kextload requires superuser privileges, so at some point some part of your script is going to need to run with elevated privileges.
    It is possible to configure sudo to allow non-admins to run any other commands. You could either allow non-admins to to run kextload or, preferably, allow them to run your shell script.
    man sudoers will give you the details on how to configure sudo to do this, which might be as simple as:
    <pre class=command>ALL  ALL=(ALL) /usr/local/bin/myscript</pre>
    This will allow all users to run /usr/local/bin/myscript as root.

  • Capturing Users with running sql in shell script after every 10min

    Hi All,
    we have a strange prob. of database crash, therefore decided to check what users do when OS/DB crashes,
    i need your input in RUNNING/SCHEDULING such a script which gathers all active users with running SQL and append in a logfile so that we are aware of what happened when DB/OS Crashed.
    i can run this run a query from V$SESSION,V$SQL, and V$PROCESS but i need your input writing such a SHELL Script and scheduling can run by CRON.
    Regards.

    Here ya go.
    (Assuming you want a script to run against one sid)
    script:
    #!/bin/ksh
    # Set environment
    . $HOME/.profile
    export ORACLE_SID=your sid
    sqlplus <<! > /some_report_file
    / as sysdba
    sql you want to execute here*
    exit
    cron entry:
    0,5,10,15,20,25,30,35,40,45,50,55 * * * * /your/script/name/here > /dev/null 2>&1

  • Running the JAZN shell in Oracle 10g

    Hello all,
    I am a student taking the Oracle 10g DBA class. I am having trouble running the JAZN shell script that will allow me to use SYSDBA and SYSOPR profiles in iSQL*Plus. I was wondering if there was someone out there who could explain this script, what it does and help me locate where my proble is.
    This is the script the book gives and say to run:
    Setting up iSQL*Plus for SYSDBA and SYSOPER Access
    These roles require special setup and authentication for security reasons. To do this you must set up a user in the Oracle Application Server Containers for J2EE (OC4J) user manager and grant access to the webDba role for the user. You must set the JAVA_HOME OS environment variable to $ORACLE_HOME/jdk.
    1. Change to the correct directory:
    Cd $ORACLE_HOME/oc4j/j2ee/isqlplus/application-deployments/isqlplus
    (I am able to get to this directory okay.)
    2. Run the JAZN shell:
    $JAVA_HOME/bin/java/-Djava.security.properties=$ORACLE_HOME \
    /oc4j/j2ee/home/config/jazn.security.props-jar $ORACLE_HOME/oc4j/j2ee/home/jazn.jar-user “iSQL*Plus DBA/admin” \
    -password welcome –shell
    (When I run type the shell as written it doesn't look like anything happens. I am in the same directory as before. I did get an error a couple of times telling me that the directory /bin/java did not exist. When I try to go into the $JAVA_HOME directory is say that it does not exist.
    --------------- I have never gotten past here ----------------------
    Now what I gather from looking at this shell is that it creates an admin profile with a password of welcome.
    3. Create a user, choosing a username and password:
    JAZN> adduser “iSQL*Plus DBA” username password
    4. Grant the webDba role to the user:
    JAZN> grantrole webDba “iSQL*Plus DBA” username
    5. Exit the JAZN shell:
    JAZN> exit
    This part looks like it is where you create the SYSDBA and SYSOPER profiles and passwords. You also grand these profiles webDba access. Then exit the shell.

    Hello Werner,
    I did have to install Java on my computer. I created a Java directory and in this directory I placed the jre1.6.0_18 file which I downloaded. This is the Java application. The path I placed it in is /usr/java/jre1.6.0_18.
    I also looked at what I thought were all my environment varriables with the $ env command and saw nothing that refered to java or JAVA_HOME.
    After setting JAVA_HOME i get an error:
    Exception in thread "main" java.lang.NoClassDefFoundError: .u01.app.oracle.product.10.2.0.db_1.oc4j.j2ee.home.jazn.jar-user
    (I have no idea what this means)
    My questions:
    Is this the file that I should be pointing to? I do not understand what the /jdk directory is.
    From what I could see from the link that you provided was the Oracle Application Server Installation Guide. Is this what you wanted me to read?

  • Creating wrapper procedures for Long running procedures

    In SQL server, we can create a wrapper procedure to call long running procedure. Wrapper procedure calls long running procedure and returns to its calling application and give message "your request has been received and being processed. result will sent to your email-id." So user need not wait for complete execution for his request. From long running stored procedure we can send email to user stating all execution result he wants.
    Is there any way to implement it in Oracle9i? Or any other technique to call such long running procedures asynchronously through wrapper procedure sothat user need not to wait and also avoid "request time out" error.

    This question would be better off posed in the Oracle Data Provider for .NET forum.
    Christian

  • Perl scripts wont run

    I have a NW65 SP5 SBS server. The perl scripts appear in the browser as a
    text file and don't run. It appears as if the perl interperter is not
    running or doesn't see the script.

    I should add I am trying to get CGI scripts to run also and not having much
    luck. Perl 5.8.4.
    "Cyrus" <[email protected]> wrote in message
    news:xZbAi.391$[email protected]..
    > Perl scripts run from the command line but not browser.
    >
    > "Guenter" <[email protected]> wrote in message
    > news:UAbAi.390$[email protected]..
    > > Hi,
    > > "Cyrus" <[email protected]> wrote in news:ShbAi.384$vI3.370@prv-
    > > forum2.provo.novell.com:
    > >
    > > > I have a NW65 SP5 SBS server. The perl scripts appear in the browser
    as
    > a
    > > > text file and don't run. It appears as if the perl interperter is not
    > > > running or doesn't see the script.
    > > the NW65 default config only executes scripts located in sys:/perl/web
    > > through mod_perl; see the file:
    > > sys:/apache2/conf/mod_perl.conf
    > >
    > > Gnter.
    > >
    >
    >

  • Need a sample file for IDQ parameter file and a Shell script to execute it from command line

    Hello,The parameter file itself is generated from cmd line using infacmd command and it automatically creates the parameters inside it based on the parameters created inside the mapping and the workflow. So, even if one provides you a paramtere file for IDQ, it might fail as your workflow definition and its paramters would be different. Thanks,K

    Hi all   My project migrated from Power Center to IDQ developer and I had to move all my mappings to IDQ developer. I was able to migrate everything except for the parameter files. It seems that the layout and syntax for parameter file is different from Power Center. Is there anyone who can help me out or send me a sample of a parameter file for IDQ? As well as a sample shell script to run the mapping or application from the Command line.This is an urgent need and It will be greatly appreciated.   ThanksNaveen Medisetti

  • Sample shell scripts to run workbooks

    Does anybody have some sample shell scripts to run the workbooks?

    Your Schedule workbooks thru command line thread contains answers.

  • Calling Shell Scripts in Business Workflow and Guided Procedures

    Hi *,
    is it possible to call shell scripts in business workflow and guided procedures? would need further documentation (how to, blog,...) about this issue.
    Thx in advance,
    Rene.

    Hello,
    Workflows consist of tasks.
    A task executed an object's method.
    Methods are written in ABAP.
    In the method you can code whatever you like, including code to execute shellscripts.
    How to do this is not really a workflow question, I would suggest asking in an ABAP forum on how to write a function module to do this in a pure ABAP context. Then it's just a matter of inserting it into a method for use in your WF.
    Cheers,
    Mike

  • Want to create unix shell script for  Clone procedure in 11i and r12

    Want to create unix shell script for Clone procedure in 11i and r12 .Can anyone help me on this as I m new to oracle apps and scripting.
    Thanks in advance .

    user11958935 wrote:
    Thanks but I want it for application cloning ie adcfgclone and autoconfig etc .Please see old threads for similar topic/discussion.
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Automate+AND+Rapid+AND+Clone&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Automate+AND+AutoConfig&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • Issue with Enter-PSSession when running from the shell and via script

    Hello
    Can someone please help me with the following issue
    If I open the PowerShell console and do the following
    Enter-PSSession -computername Server1
    "This is a test" > C:\Log.txt
    Exit-PSSession
    It works e.g. the Log.txt file is create as expected on Server1
    However if I put the exact same command in a script and execute the script.
    ./TestScript.ps1
    The Log.txt file is created on my Client (e.g. PC) and not the Server1
    I also tried using $Session = New-PSSession -ComputerName Server1 etc.....
    then Enter-PSSession -Session $Session
    I also tried Enter-PSSession etc....
    Start-Sleep -seconds 60
    "This is a test" > C:\Log.txt
    Exit-PSSession
    Again no luck when running from shell all OK, then executing as a script (again from the command line) files is created on client
    Any ideas why this is happening please and how to resolve, I am using PowerShell v4 on the client and PowerShell v2 on the Server
    Thanks
    AAnotherUser__
    AAnotherUser__

    No, the command is explicitly designed for interactive use, not within a script. If you see
    http://technet.microsoft.com/en-us/library/hh849707.aspx you'll even see it clearly state that it "Starts an interactive session with a remote computer".
    There are quite a few threads elsewhere on the same subject, all of which say the same thing, for instance
    http://powershell.com/cs/blogs/tips/archive/2010/11/15/enter-pssession-do-s-and-don-ts.aspx and
    http://powershell.org/wp/forums/topic/running-multiple-remote-commands-with-enter-pssession/ and
    http://blogs.technet.com/b/heyscriptingguy/archive/2009/10/29/hey-scripting-guy-october-29-2009.aspx and
    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/7e89b957-ff5b-42c4-b107-d7e18752fcf1/enterpssession-within-a-script
    So when you run it interactively, you've started the interactive connection to the remote computer and are now running the relevant commands on that machine. When you run it from the script it starts the remote connection, but crucially it doesn't use that
    new connection, the script is still being run in the current local session.
    When you think about it makes sense. Using the Invoke-command method you're connecting to a remote machine, sending the script block to the remote machine, and then running that block of code on the remote machine. The remote machine only knows about the
    code you send it, not the rest of the script (which is why if you use variables you have to pass them to invoke-command otherwise they won't be available to the script block on the remote machine. Conversely, when you use the Enter-PSSession method, you've
    connected to the remote machine, but you haven't passed any code to it. At that point you're on the remote machine, but it has no way to know what you want it to do since your script code is on the local machine. It can then either return to the local
    machine and run the next line of code locally (which it does), or sit there connected to the remote machine waiting input that will never come (which would be even less useful).

  • Procedure call and shell script

    When i try to pass a shell variable to a procedure call in a shell script it does not work. But a SQL command ( insert ) has no problem taking the shell variable. Has this something to do with context switch. How to get around this prbokem.
    `sqlplus <username/password> -silent << EOF
    set serveroutput on size 1000000
    exec procA; -- works
    exec procB($shell_variable); -- does not work
    insert into table1 values ($shell_variable); -- works
    EOF`
    Thanks!

    It works to me :
    TEST@db102 SQL> create or replace procedure isnumeric (num in varchar2)
      2  is
      3          a       number;
      4  begin
      5          a := to_number(num);
      6          dbms_output.put_line (num||' is a number');
      7  exception
      8          when others then
      9                  dbms_output.put_line (num||' is NOT a number');
    10* end;
    11  /
    Procedure created.
    TEST@db102 SQL> exec isnumeric(123);
    123 is a number
    PL/SQL procedure successfully completed.
    TEST@db102 SQL> exec isnumeric('abc');
    abc is NOT a number
    PL/SQL procedure successfully completed.
    TEST@db102 SQL>
    [ora102 work db102]$ cat callvar.sh
    export VAR=$1
    sqlplus -s test/test << EOF
    set serveroutput on size 1000000
    exec isnumeric('$VAR');
    EOF
    [ora102 work db102]$ ./callvar.sh 123
    123 is a number
    PL/SQL procedure successfully completed.
    [ora102 work db102]$ ./callvar.sh abc
    abc is NOT a number
    PL/SQL procedure successfully completed.
    [ora102 work db102]$                       

  • Pl/sql procedure with shell script

    Hi Guys,
    I will be updating some of the columns in the database thru SQL UPDATE stament. I want to make this process automatic. I.e instead of running manually this uodate process, i want to write a unix script which run on cron job. In the update stament I have to compare date like e_create_date > to_date (........, 'yymmdd') and date should be 2 days previous then to date and I would ike to create the spool file which I would like to send through mail.the script will run automatically.
    I am confused how to write shell script & sql procedure and how to call it inside the shell script. How can this be done.
    Help Appreciated.
    Thanks
    sonu

    save the Store procedure as a create_SP.sql in OS
    save another testrun.sql
    as follows
    begin
    sp_test('&p_test');
    end;
    If you are on a Unix or Solaris OS then
    open a Shell Script as follows :
    and name as test.sh or test.ksh
    var='SYSTEM'
    export var
    sqlplus username/password
    @create_SP.sql
    -- this created a store procedure on the database
    @testrun.sql $var
    This will execute the SP with parameter from OS Variable.

Maybe you are looking for