Shell script to launch terminal session with environment sourced

Hi all
I've installed 12.1.1 on OEL 5.
As i've installed with a single user, I will need to switch between the app and db tier.
I'd like to create two scripts, one that opens a terminal session and sources the app env file, and another one that opens the terminal session and sources the db env file.
Anyone done anything like this before?
Thanks

Hi,
As i've installed with a single user, I will need to switch between the app and db tier.
I'd like to create two scripts, one that opens a terminal session and sources the app env file, and another one that opens the terminal session and sources the db env file.
Anyone done anything like this before?Yes -- Source the application/database env file in the OS user's profile (.bash_profile or .profile), and all the environment variables should be set when you login as applmgr/oracle user.
Thanks,
Hussein

Similar Messages

  • How to write a shell script to execute a procedure with out parameter

    Hi,
    How to write a shell script to execute a procedure with out parameter.
    here is my procedure
    PROCEDURE sample(invar1 VARCHAR2,
    invar2 VARCHAR2,
    invar3 VARCHAR2,
    invar4 VARCHAR2,
    ecode out number);
    Any example really helpfull
    Thanks in advance

    Or if we're passing values in, maybe something like:
    Test procedure:
    CREATE OR REPLACE PROCEDURE p (myin IN VARCHAR2, myout OUT VARCHAR2)
    AS
    BEGIN
        myout :=
            CASE myin
                WHEN 'A' THEN 'APPLE'
                WHEN 'B' THEN 'BANANA'
                ELSE 'STARFRUIT'
            END;
    END;Shell script:
    #!/bin/bash
    my_shell_variable=$1
    unset ORACLE_PATH
    sqlplus -s un/pw@db <<-EOF
    set feedback off pause off
    set pagesize 0
    set autoprint off
    VAR out varchar2(30)
    VAR myin varchar2(30)
    exec :myin := '${my_shell_variable}'
    BEGIN
      p(:myin, :out);
    END;
    print out
    exit
    EOFTest:
    /Users/williamr: xx A
    APPLE
    /Users/williamr: xx B
    BANANA
    /Users/williamr: xx
    STARFRUITObviously in a real script you would not hardcode the password or let it show in a "ps" listing.
    Message was edited by:
    William Robertson

  • Is it possible to let KDM launch the sessions with dbus?

    well, like the subject line asks: is it possible to let KDM do something like "dbus-launch startkde" or "dbus-launch gnome-session"?
    And if yes, how? Also, shouldn't it do that by default?

    However thanks a lot for help g
    Found the answer myself: Simply sign the applet with an self-made certificate, the next time the browser is restartet there will be a promt for acceptimg the certificate.
    Cool!

  • Power Shell script to send a email with event details when an specified event occur

    I want a power shell scrip to send a email to a specific email id with the event details when an specified event triggered. The default option to trigger the email on event occur is failed.

    Why is everybody now saying "I want, I want, I want"
    Can you say what is happening?  Can you post a script with a line that is failing?  No!  All you want is a free script.
    Start by learning how to script.   Try at least to write a simple "hello World" script.  Until then you cannot post here.
    ¯\_(ツ)_/¯

  • Helpful Shell Scripts for Making Work Simpler with OVM

    Hi guys we are working on Oracle VM,
    I have created some scripts which will run on OVM Server .Hope they will be useful to you.
    These script are created keeping in mind OVM Manager is not available.
    I have created two scripts to make the following task possible through OVM Server.
    1>To take vnc console of the machine by just giving guest name.
    2>create virtual machines using template.
    Please share your views about the scripts.
    1)To take vnc console of the machine by just giving guest name.
    #This script will export DISPLAY variable globally
    if [ -z "$DISPLAY" ]
    then
    echo "Please Enter IP address of your machine"
    read ipadd
    export DISPLAY="$ipadd:0.0"
    else
    echo display is already set
    fi
    echo "Please Enter the Name of the virtual machine you want to take the console"
    read MachineName
    xm list $MachineName -l |grep 0.0.0.0: > tempdisplay
    cat tempdisplay | awk -F"0.0.0.0" '{print $NF}'> temp2display
    #sed s/"(location 0.0.0.0"/""/ tempdisplay > temp2display
    tempvariable=`sed s/")"/""/ temp2display`
    vncviewer $tempvariable &
    rm -f tempdisplay
    rm -f temp2display
    Edited by: user10373165 on Nov 22, 2009 10:46 PM

    You probably want to wrap your code samples with a tag.  It looks like some of the script text is not showing up.                                                                                                                                                                                                                                               

  • Power shell script to add multiple aliases with a .csv file.

    I have an email address lets say [email protected] and I need 1000 aliases added to the email. For example [email protected], [email protected] etc etc. and I have a .csv file with 990 columns with just project1, project2.
    Is there a way to run a command in powershell exchange to import all the aliases I need in a few commands? Can someone point me in the right direction if I am in the wrong forum also? Thanks
    No sure if this is correct or not:
    > $mbx = Get-Mailbox Project
    > Import-CSV "C:\SomePath\wherever.csv" | foreach { $mbx.EmailAddresses += $._SmtpAddress }
    > Set-Mailbox project -EmailAddresses $mbx.EmailAddresses

    Help Import-Csv -FULL
    $aliases=Import-Csv aliases.csv
    ¯\_(ツ)_/¯

  • How to use "do shell script" when Terminal replies with a prompt?

    Hey all,
    I'm wondering how to properly use "do shell script" when Terminal replies with a question? In this example, I'm building a small tool in AppleScript that will auto-update the Android SDK via command line prompts. The problem is when I tell it to update all ("update sdk --no-ui"), I need to accept licence agreements before it continues, and the amount of licence agreements brought up is different every time.
    So, basically, I'm wondering how to handle a case where "do shell script" encounters a case where Terminal would normally need a user's response to?
    Thanks,
    Behn

    If it is variable number of prompts that is a problem.  Look around hd and figure out how many prompts there will be. Ask around android forum for a bash solution. There are some test case apps that will let you put conditionals on output from running programs.
    # traditional way.  Pipe output to command.
    do script "echo 'ok' | update sdk --no-u"
    Here is the preferred way of getting administrator privileges.
    It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on.  Here is an example.
        Author: rccharles
        For testing, run in the Script Editor.
          1) Click on the Event Log tab to see the output from the log statement
          2) Click on Run
        For running shell commands see:
        http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
    on run
        -- Write a message into the event log.
        log "  --- Starting on " & ((current date) as string) & " --- "
        --  debug lines
        set unixDesktopPath to POSIX path of "/System/Library/User Template/"
        log "unixDesktopPath = " & unixDesktopPath
        set quotedUnixDesktopPath to quoted form of unixDesktopPath
        log "quoted form is " & quotedUnixDesktopPath
        try
            set fromUnix to do shell script "sudo ls -l  " & quotedUnixDesktopPath with administrator privileges
            display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
        on error errMsg
            log "ls -l error..." & errMsg
        end try
    end run

  • Trying to close an app with a shell script which was launched by same app.

    This may be simple, but is confusing me. I have an app that executes a shell script at launch. The script is designed to check for the existence of files and if not found, I want to display a message and close the application. The problem seems to be that I can't close the app with the script, since the script was called by the app and the shell is tied up. Does that make sense? I can't close the app because the script/shell is still active. Any ideas?

    Just have the script output some value for the app to read and then quit. Once the app reads the value, it will wait for the script to quit (shouldn't take long, especially if the script isn't running anymore) and then, if the value is a flag to quit, quit.

  • Problems to run shell scripts in terminal

    Hey mates,
    I'm not very experienced in writing shell scripts. However, I received a few shell scripts I wanted to execute. I used following command:
    chmod u+x model.sh
    I did not received any error message so that I think that this command works. Afterwards, I wanted to run these file with:
    ./model.sh
    However, it doesn't work, I receive an error message:
    -bash: ./model.sh: /bin/sh^M: bad interpreter: No such file or directory
    If I choose another shell script of my colleague I can run it and it works properly. What's the problem?
    I use in all shell scripts the same syntax starting with
    "! /bin/sh
    Thus, I don't see the reason why the first script isn't running while the second one is fine.
    Help appreciated!
    cheers,
    Thomas

    Unix and Terminal questions are best asked in the Mac OS X Technologies > Unix Forum
    <http://discussions.apple.com/forum.jspa?forumID=735>
    As jsd2 has pointed out, you CANNOT have Windows <CR><LF> line terminators in your file (aka ^M^J). Just about every Unix shell will choke on the <CR>
    We run into this problem all the time with users moving Unix shell scripts through a Windows system and having Windows convert the <LF> terminated Unix files into Windows <CR><LF> files, and then either use them in a Windows Cygwin environment (where they "Barf"), or move them back to a Unix system with the <CR><LF> line terminations still in the scripts, and they "Barf".
    You can look at the contents of your scripts using the following command
    cat -v script.name
    Any ^M characters found at the end of lines will be part of <CR><LF> Windows line terminators.
    You can use the following command to remove the <CR> from those files
    tr -d '
    ' <script.name >new.name
    chmod +x new.name
    If you wish to pursue this further, I would suggest using the Mac OS X Technologies > Unix Forum
    <http://discussions.apple.com/forum.jspa?forumID=735>

  • Running shell script from terminal

    If I run this shell script from the terminal it plays the sound though my external speakers;
    volume="/Volumes/8GIGSTICK"
    if mount|grep $volume; then
    afplay -d /System/Library/Sounds/insert.wav
    rsync -a /volumes/8GIGSTICK/documents /Users/mcp/Documents/Microsoft\ User\ Data/
    else
    say not mounted
    fi
    If I have launchd run it when the volumes is mounted it only plays the sound through the internal computer speaker.
    Anyone know why and how I can fix it?

    It's probably because your launchd job isn't running in the Aqua context and therefore doesn't pick up your sound-output preferences. One way to overcome this would be to load the job as follows:
    launchctl load -S Aqua -D user job_label
    That's assuming you have a launchd property list at ~/Library/LaunchAgents/job_label.plist. To make the effect persist across login sessions, you would create a file ~/.launchd.conf with the contents
    load -S Aqua -D user job_label

  • Shell Scripts: "Open [ALL] With" Emacs

    Hi All,
    I'm trying to figure out a way to open ALL shell scripts (for which I use the extension ".sh") with emacs (launched in the terminal) by default.
    I've made some progress towards this goal, but am stuck on the last step. Here's what I've done:
    [1] I copied an Apple Script (from here: http://hints.macworld.com/article.php?story=20031027142625782) to create an Application (which I've called "Emacs_open_with.app"), that when launched with a file, will open it in emacs in the terminal.
    [2] I can make Emacs_open_with.app the default launch app for a individual shell script by right-clicking -> Open With -> Other... -> Emacs_open_with.app (+ check the box "Always Open With). However, doing this will only make it the default app for that single shell script, not for all of them, as I desire.
    [3] Normally, one can associate an application with a file extension, such that any file with that extension will be launched by default by this associated application, by: Right-clicking a file -> Get Info -> Open With -> Other... -> [DESIRED APP] (+ check the box "Always Open With) -> Change All... -> Click Continue when the pop-up appears which asks "Are you sure you want to change all similar documents to open with the application...". However, this does NOT work for Emacs_open_with.app; as soon as I click continue, the drop-down menu which I had used to select "Emacs_open_with.app" changes back to another, different Application.
    Any idea about how best to tackle this problem? Thanks for your help!

    Ilmari Aalto wrote:
    Hi Darth,
    Thanks for your hint! Nevertheless I think it's something more profound, since there's no error etc. For example, should I have the path wrong I assume that OWB would return me some kind of an error when it doesn't find the .sh-file? Isn't there any log-file to see whether the command was executed? It seems like the execution of the User Defined element would be skipped altogether.
    Cheers,
    IlmariNo, if you don't give an absolute path OWB will not return any error, it just wont do anything at all...

  • Error Handling with sql *plus from a shell script

    When I execute sql plus in a shell script with the wrong username/pass pair, the shell script hangs without terminating. What is the proper way to execute sql plus in a shell script that will catch a login failure and make sure the script doesn't hang?
    Example:
    We execute the following in our shell script:
    sqlplus ${ORACLE_INST} @./sql/ftp_ledger_put.sql
    Now if somebody comes along and alters the login then the script would hang. Is there a way to have the script exit gracefully?

    Not the most elegant solution but.......
    sqlplus &lt;&lt;EOD 2&gt;&1 &gt;some_log_file
    user/pwd
    @somescript
    exit
    EOD
    Because sqlplus allows for 3 tries at log in if user/pwd is not valid it will try to use subsequent lines. Each will fail.
    You have to look in some_log_file to determine success/failure
    Ken

  • Closing active terminal window with applescript

    I made a very basic script to lock my screen, and I like how it works. Some of my co-workers would also like it but it has one problem.
    When the script runs, a terminal box pops up at the end saying [process complete]. I can click through this and I don't care, they do.
    I can't just killall terminal because we use terminal and that could kill our work.
    We sometimes need to see output from a script and like the process complete, so don't want to reconfigure our systems to never display it.
    I'm trying to find a way to use applescript or something to kill the active terminal window, or the window with the title of LockScreen or something.
    Anyone have an idea?
    I was hoping something like this would exist but it doesn't seem to: tell application "Terminal" to close window

    Here is an easy approach.  Start Applications -> Automator
    Select Application
    In Automator search for "Start Screen Saver".  This should be under Library->Utilities
    Drag "Start Screen Saver" to the right side panel.
    Save the Automator app.
    If the user has System Preferencs -> Security -> Require Password ... set, then one the screen saver has started running, it will require the user to enter their password before getting control back.
    This Automator app can be double clicked, it will not require the terminal.
    With respect to your script.  If this is a shell script, AND if you wish to continue using it, then you could create an Automator app that uses "Run Shell Script" under Automator Library->Utilities.  This will also NOT require the use of Terminal, however, be aware that when Automator runs a shell script it DOES NOT have the same environment as when you are running a shell script at your Terminal prompt.  There are very few environment variables set, and for example the USER, HOME, current working directory, PATH, etc... may not be the same.  If you have dependencies on specific environment information, you may want to write a simple automator script the using "Run Shell Script" to output various environment information into a file so you can see what you have to work with
    (id -a
    pwd
    echo "$#"
    echo "$@"
    printenv
    ) >/tmp/automator.environment.txt

  • Displaying an alert (Applescript or otherwise) from shell script?

    I have a point in a shell script where I'd like to put up an alert dialogue on a particular error condition. The script runs in the background and doesn't have a terminal window. I tried writing a little applescript that uses the applescript alert command and call it using osascript from my shell script, but it doesn't work. If I enter "osascript ~/myscript.scpt" in a terminal window, I get the error message "/Users/Ted/myscript.scpt: execution error:No user interaction allowed. (-1713)" (If I run myscript.scpt from the script editor it does what I want it to do.) Any ideas? I suppose I could have my shell script create a file in some folder and have my applescript be triggered as a folder action, but that seems pretty roundabout!

    Thanks -- I apologize for not doing a more thorough search! Yes, that comes very close to addressing my need, but I have run into one difficulty. If I run my shell script from the terminal (pasting it in) everything works fine. If I run it as a packaged app (with Platypus) everything works like it's supposed to, except that the alert applescript (it's just a one line script) briefly flashes the alert dialogue when it's supposed to and then dies, rather than waiting 10 seconds or until I click OK. I'll have to experiment and see if I can tell what's going on.

  • How to shell script for noob? or Cryptography for someone who doesn't need.

    Hi, I've seen the need of automating some tasks in the Terminal and I believe using shell scripts is my solution, although I don't really even understand how they work.
    Instead of posting a full how-to here, I'd like to ask if anyone knows about good comprehensive guide for someone who never used any programming language, yet knows how to work a bit with the Terminal?
    I will figure out the command I will need to input in the Terminal myself, by testing. Once it's figured all I need is to make a shell script out of it, and perhaps make an application out of it. (Automator? ... or more Script Editor? Or?)
    Thanks
    After seing this page...
    http://www.askdavetaylor.com/howcan_i_secure_encrypt_folders_on_my_macs_usb_flashdrive.html
    ... I believed to have found a great solution for some heavy cryptography, to protect some folder and for learning pleasure. What I wanted to do is to automate the openssl task mostly like this:
    Open my flash drive (or a certain folder) containting a disk image (uncompressed, or compressed if necessary, doesn't matter) but uncrypted. Clicking on something I will name 'Lock' for the moment will run the shell script, encrypting the said image with pre-set parameters and a password I will input when prompted by the app.
    Re-running the app will prompt me a password and simply un-encrypt the image, making it useable for me.
    That's all. Perhaps if I can do it, I'll make it prompt me what cipher and all other parameter to use, but I don't understand openssl very well yet. *I just read and understood more or less informations on that page.*
    Who knows, I'll end up with a sweet GUI for encrypting files usable by the common mortals.

    The Advanced Bash Scripting Guide is a great resource for beginners thru advanced users- http://tldp.org/LDP/abs/html/index.html

Maybe you are looking for