Exiting a script

I have a script that contains a combination of SQL commands and PL/SQL procedures. I want to exit my script if I receive an exception in one of the procedures so that the rest of the SQL does not continue. Is there any way to do this?

Rick,
If you are in a UNIX environment, you can implement this using a shell script.
For example;
sqlplus << EOS
spool filename.log
EXEC PL/SQL statement OR
SQL STATEMENT
spool off;
exit;
EOS
Test the log file to see if there is an error by grep[ING]
then exit otherwise dosomething.
I hope this logic helps.
Regards,
John

Similar Messages

  • How to get 'exit event' script to execute again when form file with saved data is re-opened?

    I have created an Adobe Dynamic XML Form using LiveCycle Designer with many fields / subforms that are ‘visible’ or ‘hidden’ dependent upon the options selected from various Drop-Down Lists. The form has also been save-enabled. Users can successfully complete the form and save a copy with the data that has been input.
    The problem I have is that when the saved file is re-opened the ‘hidden’ fields / subforms which were previously made visible by selection of the appropriate options from the Drop-down Lists are now NOT displayed. However if you make the same selections from each of the Drop-down Lists AGAIN the hidden fields / subforms are displayed and do contain the data that was entered.
    The problem appears to be that the script which determines whether a field / subform is ‘hidden’ or ‘visible’ is an
    <event activity="exit" name="event__exit">
    which is followed by
    if (this.rawValue == "0")- (i.e. the value of the Drop-down List)
    sfCompanyDetails.presence = "visible";
    sfRecruitmentAgency.presence = "hidden";
    etc, etc
    and, therefore, it is not executed again when the saved file is re-opened.
    Can anyone please advise how to achieve this?

    Moved from Adobe Connnect Forums.

  • How to exit Maxl Script

    Hi,
    In the tech ref, "It is not necessary to exit at the end of MaxL script files or stream-oriented input (using the -i switch)". How is this done?
    I want to run a DOS batch after the Maxl script is done.
    Thanks.

    Nevermind I figured it out. I changed the .bat command to follow.

  • Exit Shell Script Concurrent Program as Warning

    Hi,
    I have a shell script (bash, Oracle Enterprise Linux) defined as a concurrent program in R12.
    I am wondering what exit status will cause the program to exit in 'Warning'.
    I have tried many values but can only seem to get it to exit in 'Normal' or 'Error'.
    Any help would be appreciated.
    Thanks

    Currently you can complete the host program with 'Success' (return 0) or 'Error' (return anything else).
    To return warning you need to update return status prgramatically.
    HTH
    Dinesh

  • Exit Button script won't work in Adobe Reader 8

    Hello,
    I have this code on Exit button for pdf form:
    app.execMenuItem("Close");
    Or
    to give warning before Exit: Have a second RealExit Button hidden to execute the code
    var answer = xfa.host.messageBox("Are you sure you want to Exit?","Warning Message",2,1);
    if(answer==1){
    RealExit.execEvent('click');
    I tried both the code one at a time but no luck in Adobe Acrobat Version 8, works like a charm in Adobe Acrobat 9
    I would like the user to click the Exit button if they choose to exit. However it doesn't work in Adobe Acrobat 8 but works in 9 version. Is there a work around? Any suggestions???
    Thanks

    This answer may not be a big help but sure will give you some level of understanding....
    Check the URL>>>http://kb2.adobe.com/cps/402/kb402673.html
    Check the section "PDF Forms-related issues:" starting mid page.....
    Not all releases/versions are good. Some releases tend to have some bugs...the version you tested could be one of them. Adobe always recommends to be on the latest version. If client still on older version that is client's problem especially there should not be any restrictions on upgrading to Latest version when the software is free!

  • ORA-27369 Exit-Code: 255 when executing sql script as job

    Dear all
    I'd like to find and compile all invalid objects in an instance. This should be done every day as a scheduled job with the use of DBMS_SCHEDULER.
    For this, I set up the following sql-script:
    ---------start script--------------
    set heading off;
    set feedback off;
    set echo off;
    Set lines 999;
    Spool /tmp/run_invalid.sql
    select
    'ALTER ' || OBJECT_TYPE || ' ' ||
    OWNER || '.' || OBJECT_NAME || ' COMPILE;'
    from
    dba_objects
    where
    status = 'INVALID'
    spool off;
    set heading on;
    set feedback on;
    set echo on;
    @/tmp/run_invalid.sql
    exit
    ------ end script ----
    The script ist working well when executed manualy via sqlplus. As you can see, it spools the commands to a second file (run_invalid.sql) which is the beeing executed to compile the invalid objects found.
    I now want to schedule this script via DBMS_SCHEDULER (running the job every day at 7AM). Creation of the job:
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'compile_invalid_objects',
    job_type => 'EXECUTABLE',
    job_action => '/home/oracle/scripts/sql/compile_invalid_objects.sql',
    start_date => trunc(sysdate)+1+7/24,
    repeat_interval => 'trunc(sysdate)+1+7/24',
    enabled => TRUE,
    comments => 'SQL-Script, und invalid objects zu finden und zu kompilieren'
    END;
    Manualy execute and error message:
    BEGIN
    DBMS_SCHEDULER.RUN_JOB (job_name => 'compile_invalid_objects',
    use_current_session => true);
    END;
    FEHLER in Zeile 1:
    ORA-27369: Job vom Typ EXECUTABLE nicht erfolgreich mit Exit-Code: 255
    ORA-06512: in "SYS.DBMS_ISCHED", Zeile 150
    ORA-06512: in "SYS.DBMS_SCHEDULER", Zeile 441
    ORA-06512: in Zeile 2
    --> Sorry for this, I'm using german localized oracle.
    Unfortunately, it seems that only Shell-Scripts can be scheduled when using job_type='EXECUTABLE'. Can you confirm this?
    BTW: The script is chmoded to 777, therefore it can't be a permission problem.
    Is there maybe another solution with one single script using dbms_output functionality and run the script in a loop?
    To complete my post, here are the commands used to create and test the job:
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'compile_invalid_objects',
    job_type => 'EXECUTABLE',
    job_action => '/tmp/compile_invalid_objects.sql',
    start_date => trunc(sysdate)+1+7/24,
    repeat_interval => 'trunc(sysdate)+1+7/24',
    enabled => TRUE,
    comments => 'SQL-Script, und invalid objects zu finden und kompilieren'
    END;
    Thanks for your help
    Casi

    You could more simply use $ORACLE_HOME/dbms/admin/utlrp.sql

  • RMAN exit problem from linux script..

    Hi all
    I am using 11.1.6.0 on linux centos ..below is the rman script (name is rmanbackup.sh) .
    rman target / <<- EOF
    sql 'alter system archive log current';
    run {
    backup current controlfile;
    exit
    EOF
    echo "script complete for rman backup"
    mkdir /home/oracle/backup_dir
    cp /home/oracle/backup_dir /home/oracle/backup_dir1
    when i execute this, rman exit from script without executing the last 3 operating system commands .
    any help in this regard.

    As Mseberg said, Please try to mark you questions as answered, here is the answer:
    add *#!/bin/ksh* in your script ; also cp -r not cp
    [oracle@wissem ~]$ cat rmanbackup.sh
    #!/bin/ksh
    rman target / <<- EOF
    sql 'alter system archive log current';
    run {
    backup current controlfile;
    exit
    EOF
    echo "script complete for rman backup"
    mkdir /home/oracle/backup_dir
    cp -r /home/oracle/backup_dir /home/oracle/backup_dir1
    [oracle@wissem ~]$ ./rmanbackup.sh
    Recovery Manager: Release 11.2.0.1.0 - Production on Sun Aug 28 17:00:11 2011
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    connected to target database: ORAWISSE (DBID=3964208472)
    RMAN>
    using target database control file instead of recovery catalog
    sql statement: alter system archive log current
    RMAN> 2> 3>
    Starting backup at 28-AUG-11
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=149 device type=DISK
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    including current control file in backup set
    channel ORA_DISK_1: starting piece 1 at 28-AUG-11
    channel ORA_DISK_1: finished piece 1 at 28-AUG-11
    piece handle=/home/oracle/app/oracle/flash_recovery_area/ORAWISSE/backupset/2011_08_28/o1_mf_ncnnf_TAG20110828T170014_75np001q_.bkp tag=TAG20110828T170014 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
    Finished backup at 28-AUG-11
    RMAN>
    Recovery Manager complete.
    script complete for rman backup
    [oracle@wissem ~]$ ls -rtl /home/oracle/backup_dir
    total 0
    [oracle@wissem ~]$ ls -rtl /home/oracle/backup_dir1/
    total 4
    drwxr-xr-x 2 oracle oinstall 4096 Aug 28 17:00 backup_dir
    [oracle@wissem ~]$ ls -rtl /home/oracle/backup_dir1/backup_dir/
    total 0
    [oracle@wissem ~]$

  • Conditional Exit from the script

    Hi,
    I have to code the script like the below
    --Step 1
    begin
    If <Table1 doesnot exist> then
    Display "User Defined Error Message: Table1 doesnot exit"
    EXIT FROM THE SCRIPT(Below sql should not run)
    endif
    end
    --Step 2
    spool abc.txt;
    select "should not run" from Table1;
    spool off;Step 2 should not run if table1 doesnot exist.
    Can someone please tell how to conditionally exit the script.
    Thanks & Regards,C
    CDPrasad
    Edited by: cdprasad on Aug 12, 2010 1:35 PM
    Edited by: cdprasad on Aug 12, 2010 1:36 PM
    Edited by: cdprasad on Aug 12, 2010 1:38 PM
    Edited by: cdprasad on Aug 12, 2010 1:38 PM

    Hi,
    David is right; SQL*Plus is the wrong tool for this job.
    If you really want to to this in SQL*Plus, you can achieve a crude type of branching by using sub-sripts. Instead of an IF statement, you use START or @ to run one or another of those sub-scripts, based on a substitution variable, which in turn is set by a query.
    For example:
    --     abc.sql - Test if table1 exists, and
    --                     (1) if it exists, run abc_query.sql to do a query
    --                     (2) if it does not exist, run abc_error.sql to display an error message
    --     Preliminary query, to define next_script:
    COLUMN     next_script_col        NEW_VALUE next_script
    SELECT     CASE      COUNT (*)
             WHEN  0  THEN  'abc_error'
                       ELSE  'abc_query'
         END     AS next_script_col
    FROM     all_tables
    WHERE     table_name     = 'TABLE1'
    AND     owner          = 'SCOTT'
    --     Now that we know what to do, do it:
    @&next_scriptYou would run the above script (abc.sql) and it would decide whether to run the script containing you query, or the script that prints an error message.
    Why does table1 sometimes disappear? In a good database design, tables are permanent structures, and get dropped only when they are obsolete. Perhaps you should be TRUNCATing the table, not dropping it.

  • Need help with Holiday script

    Hi All,
    I am not sure why my Holiday scripts keep returning Null, I have attached the script and xml files.
    If someone can help would be great.
    Thanks,
    Hamed

    So if you read through the logic of the script, it looks for Hokiday1 in the XML file theN Holiday2 then Holiday3, etc. As soon as it find one that doesn't exist is when the loop ends. If it doesn't find any, it returns null. Since your XML file starts with Holiday2, it returns null when looking for Holiday1 and then exits the script. I would try changing your XML file to begin with Holiday1 and aee what the debugging looks like after that.

  • Directory Binding Script (Active and Open Directory) 10.7

    Hi everyone
    I'm reposting this in the right thread. I've written a Directory Binding Script for 10.6 and ported it now to 10.7 as among the things that have changed in the upgraded version is a refurbished directory binding enviroment.
    The original thread can be found here: https://discussions.apple.com/thread/3090068. The script is applicable for clients as well and simplifies the binding process considerably.
    Be aware that the reformatted script here contains some faulty line breaks. So you'll have to correct them in a proper text editor.
    #!/bin/sh
    #Uncomment the following line to abort the script on errors
    #trap exit ERR
    ## Script to automate OD and AD Binding of Mac OS X 10.7 Servers
    ## Script written by Marc Horat, URZ Basel, 11.6.2010
    ## Updated: 12.08.2011
    # With the use of the following sources as inspiration:
    # http://www.howtomac.co.uk/?p=247
    #Created by Ross Hamilton
    #Clock restart / Remove existing settings
    #Join to Open Directory and Active Directory
    # Bombich's AD-Bind Script:
    # This script binds to AD and configures advanced options of the AD plugin
    # As this scripts contains a password, be sure to take appropriate security
    # precautions
    # A good way to run this script is to set it as a login hook on your master machine
    # Because it only needs to be run once, the last thing this script does is to delete
    # itself. If you have another login script that you typically run, include the
    # script on your master machine, and indicate its path in the "newLoginScript"
    # variable.
    # If running this as a one-time login hook to bind to AD after imaging,
    # be sure to enable auto-login (for any local user) before creating your master image
    #################CONFIGURATION##########################
    #OD
    # These variables need to be configured for your env
    odAdmin="YOURODADMIN" #enter your OD admin name between the quotes
    odPassword="YOURODPW"  # Enter your OD admin password between the quotes
    oddomain="YOURODDOMAIN" # FQDN of your OD domain
    computerGroup="YOURNEWODCOMPGROUP"  # Add appropriate computer group you want machines to be added to, case sensitive
    oldComputerGroup="YOUROLDODCOMPGROUP" # If the Computer is in a Group already
    #AD
    # Standard parameters
    domain="YOURADDOMAIN"                              # fully qualified DNS name of Active Directory Domain
    domainname="YOURADDOMAINNAME"                    #Name of the Domain as specified in the search paths
    udn="YOURADADMIN"                              # username of a privileged network user
    password="YOURADPW"                                                  # password of a privileged network user
    ou="OU=YOUR,OU=OU,OU=URZ,OU=IN,DC=YOUR,DC=AD,DC=DOMAIN"                    # Distinguished name of container for the computer E.G. OU=Macs,OU=Computers,DC=AD,DC=DOMAIN,DC=CH
    # Advanced options AD Plugin
    alldomains="disable"                              # 'enable' or 'disable' automatic multi-domain authentication
    localhome="disable"                              # 'enable' or 'disable' force home directory to local drive
    protocol="smb"                                        # 'afp', 'smb' or 'nfs' (since 10.7) change how home is mounted from server
    mobile="enable"                              # 'enable' or 'disable' mobile account support for offline logon
    mobileconfirm="enable"                    # 'enable' or 'disable' warn the user that a mobile acct will be created
    useuncpath="enable"                              # 'enable' or 'disable' use AD SMBHome attribute to determine the home dir
    user_shell="/bin/bash"                    # e.g., /bin/bash or "none"
    preferred="-preferred $domain"          # Use the specified server for all Directory lookups and authentication
    # (e.g. "-nopreferred" or "-preferred ad.server.edu")
    admingroups="$domainname\YOURADADMINGROUP" # These comma-separated AD groups may administer the machine (e.g. "" or "APPLE\macadmins")
    packetsign="allow"                              # allow | disable | require
    packetencrypt="allow"                    # allow | disable | require
    passinterval="14"                              # number of days
    namespace="domain"                              # forest | domain
    # Login hook setting -- specify the path to a login hook that you want to run instead of this script
    newLoginHook=""                    # e.g., "/Library/Management/login.sh"
    ################################# End of configuration
    ############ Begin of Script
    # Host-specific parameters
    # computerid should be set dynamically, this value must be machine-specific
    # This value may be restricted to 19 characters! The only error you'll receive upon entering
    # an invalid computer id is to the effect of not having appropriate privileges to perform the requested operation
    #computerid=`/sbin/ifconfig en0 | awk '/ether/ { gsub(":", ""); print $2 }'` # MAC Address
    #computerid=`hostname | sed 's/.unibas.ch//'`
    #computerid=`/usr/sbin/scutil --get LocalHostName | cut -c 1-19` # Assure that this will produce unique names!
    #computerid=`/usr/sbin/scutil --get LocalHostName`
    computerid=`scutil --get ComputerName`
    adcomputerid=`echo "$computerid" | tr [:lower:] [:upper:]`
    # These variables probably don't need to be changed
    # Determing if any directory binding exists
    nicAddress=`ifconfig en0 | grep ether | awk '{print $2}'`
    if dscl localhost -list /LDAPv3 | grep . > /dev/null
    then
              check4ODtmp=`dscl localhost -list /LDAPv3 | grep -n 1 | sed 's/1://' | sed 's/2://'`
              check4OD=${check4ODtmp//[[:space:]]/}
              echo "Found LDAP: "$check4ODtmp
              check4ODaccttmp=`dscl /LDAPv3/"$check4OD" -read Computers/"$computerid" RealName | cut -c 11-`
              check4ODacct=${check4ODaccttmp//[[:space:]]/}
              echo "Found LDAP-Computer-Account: "$check4ODacct
    else
              check4OD=""
              check4ODacct=""
              echo "No bound LDAP Server found"
    fi
    if [ $oldComputerGroup != "" ] && dscl localhost -list /LDAPv3 | grep . > /dev/null
    then
              check4ODgroupMembershiptmp=`dscl /LDAPv3/"$check4OD" -read ComputerGroups/"$oldComputerGroup" | grep "$computerid"`
              check4ODgroupMembership=$check4ODgroupMembershiptmp
              echo "LDAP Group Membership in Group: "$oldComputerGroup
    else
              check4ODgroupMembership=""
              echo "No LDAP Group Membership defined or not bound to a server"
    fi
    if dscl localhost -list "/Active Directory" | grep $domainname > /dev/null
    then
              check4ADtmp=`dsconfigad -show | grep "Active Directory Domain" | sed 's/Active Directory Domain//'  | sed 's/=//'`
              check4AD=${check4ADtmp//[[:space:]]/}
              echo "Found AD: "$check4AD
              check4ADaccttmp=`dsconfigad -show | grep "Computer Account" | sed 's/Computer Account//' | sed 's/=//'`
              check4ADacct=${check4ADaccttmp//[[:space:]]/}
              echo "Found AD-Account: "$check4ADacct
    else
              check4AD=""
              check4ADacct=""
              echo "No AD-Account found"
    fi
    osversionlong=`sw_vers -productVersion`
    osvers=${osversionlong:3:1}
    #Time Sync
    #Restart ntpdate
    StartService ()
    if [ "${TIMESYNC:=-YES-}" = "-YES-" ] && ! GetPID ntpd > /dev/null; then
              CheckForNetwork
    if [ -f /var/run/NetworkTime.StartupItem -o "${NETWORKUP}" = "-NO-" ]; then exit; fi
              touch /var/run/NetworkTime.StartupItem
              echo "Starting network time synchronization"
    # Synchronize our clock to the network’s time,
    # then fire off ntpd to keep the clock in sync.
              ntpdate -bvs
              ntpd -f /var/run/ntp.drift -p /var/run/ntpd.pid
    fi
    echo ""
    echo ""
    sleep 5
    #### Removing any existing directory bindings
    #Clear OD Computer Account and delete entry from Computer group
    if dscl localhost -list /LDAPv3 | grep . > /dev/null
    then
              echo "This computer is bound to the following Open Directory Services:"
              dscl localhost -list /LDAPv3
              echo "With the Search Path entries:"
              dscl /Search -read / CSPSearchPath | grep /LDAP
              sleep 5
              if [ "${check4ODacct}" == "${computerid}" ]
              then
                        echo "This machine already has a computer account on $oddomain."
                        # Set the GUID
                        GUID="$(dscl /LDAPv3/$oddomain -read /Computers/${computerid} GeneratedUID | awk '{ print $2 }')"
                        echo "Found GUID: "$GUID
                        if [ "$oldComputerGroup" != "" ] && [ "$check4ODgroupMembership" != "" ]
                        then
                                  echo "Removing entry from group $oldComputerGroup"
                                  dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$check4OD" -delete /ComputerGroups/"$oldComputerGroup" GroupMembership "${computerid}"
                                  dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$check4OD" -delete /ComputerGroups/"$oldComputerGroup" GroupMembers "${GUID}"
                                  dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$check4OD" -delete /ComputerLists/"$oldComputerGroup" Computers "${computerid}"
                        fi
                        echo "Removing Computer entry $computerid in OD"
                        dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$check4OD" -delete /Computers/"${computerid}"
              fi
              #List existing Directories
              echo "Removing OD-Binding to "$check4OD
              dsconfigldap -r "$check4OD"
              echo "Removing Search Path entries"
              dscl /Search -delete / CSPSearchPath /LDAPv3/"$check4OD"
              dscl /Search/Contacts -delete / CSPSearchPath /LDAPv3/"$check4OD"
              dscl /Search -delete / CSPSearchPath /LDAPv3/"$check4OD"
              sleep 5
    else
              echo "No LDAP or OD Binding present.";
    fi
    echo ""
    # Check a second time in order to delete any remaining LDAP-Bindings
    echo "Scanning for further LDAP servers"
    if dscl localhost -list /LDAPv3 | grep . > /dev/null
    then
              echo "Found:"
              dscl localhost -list /LDAPv3
              echo "Removing OD-Binding to "$check4ODtmp
              dsconfigldap -r "$check4ODtmp"
              dscl /Search -delete / CSPSearchPath /LDAPv3/"$check4ODtmp"
              dscl /Search/Contacts -delete / CSPSearchPath /LDAPv3/"$check4ODtmp"
              dscl /Search -delete / CSPSearchPath /LDAPv3/"$check4ODtmp"
              sleep 5
    else
              echo "No further LDAP or OD Binding present."
    fi
    echo ""
    echo ""
    #Remove the Active Directory binding
    if [ "$check4AD" != "" ]
    then
              echo "This computer is bound to the following Active Directory Services:"
              dscl localhost -list "/Active Directory"
              echo "With the Search Path entries:"
              dscl /Search -read / CSPSearchPath | grep /Active
              sleep 5
              echo "Removing any existing AD-Binding to "$check4AD
        dsconfigad -f -remove -username "$udn" -password "$password"
        echo "Removing Search Path entries"
              if [ "$preferred" != "-nopreferred" ]
              then
                        dscl /Search -delete / CSPSearchPath /Active Directory/"$domainname"
                        dscl /Search/Contacts -delete / CSPSearchPath /Active Directory/"$domainname"
                        dscl /Search -delete / CSPSearchPath /Active Directory/"$domainname"
              fi
              dscl /Search -delete / CSPSearchPath "/Active Directory/$domainname/All Domains"
              dscl /Search/Contacts -delete / CSPSearchPath "/Active Directory/$domainname/All Domains"
    #remove search path entries from 10.6
        if dscl /Search -read / CSPSearchPath | grep /Active > /dev/null
        then
            dscl /Search -delete / CSPSearchPath "/Active Directory/$domainname/$domain"
            dscl /Search/Contacts -delete / CSPSearchPath "/Active Directory/$domainname/$domain"
        fi
              sleep 5
    else
              echo "No Active Directory Binding present."
    fi
    echo ""
    #Remove Existing Directory Services Config
    echo "Removing existing DS Config"
    if [ -d "/Library/Preferences/edu.mit.Kerberos" ]
    then
              rm -R /Library/Preferences/edu.mit.Kerberos
    fi
    if [ -d "/etc/krb5.keytab" ]
    then
              rm -R /etc/krb5.keytab
    fi
    # Clean up the DirectoryService configuration files
    rm -Rfv /Library/Preferences/DirectoryService/*
    #OD
    echo ""
    echo ""
    echo "Binding to OD-Damin "$oddomain
    sleep 5
    dsconfigldap -v -a "$oddomain" -n "$oddomain" -c "$computerid"
    echo "Killing opendirectoryd"
    killall opendirectoryd
    sleep 5
    echo "Adding computer account $computerid to /LDAPv3/${oddomain} on $oddomain"
    dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$oddomain" -create /Computers/"$computerid" ENetAddress "$nicAddress"
    dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$oddomain" -merge /Computers/"$computerid" RealName "$computerid"
    # Set the GUID
    GUID="$(dscl /LDAPv3/$oddomain -read /Computers/${computerid} GeneratedUID | awk '{ print $2 }')"
    # Add computer to ComputerList and ComputerGroup
    if [ $computerGroup != "" ]
    then
              echo "Adding computer $computerid to OD group $computerGroup on $oddomain"
              dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$oddomain" -merge /ComputerLists/"$computerGroup" apple-computers "$computerid"
              dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$oddomain" -merge /ComputerGroups/"$computerGroup" apple-group-memberguid "${GUID}"
              dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$oddomain" -merge /ComputerGroups/"$computerGroup" memberUid "$computerid"
    fi
    echo "Finished OD Binding."
    sleep 5 # Give DS a chance to catch up
    echo ""
    echo ""
    echo "Performing the AD Binding"
    #AD
    # Activate the AD plugin
    defaults write /Library/Preferences/DirectoryService/DirectoryService "Active Directory" "Active"
    plutil -convert xml1 /Library/Preferences/DirectoryService/DirectoryService.plist
    #Use the existing AD-Computername or generate a new one
    computeridtmp="default"
    if [ "$check4ADacct" == "" ]
    then
              LEN=$(echo ${#adcomputerid})
              if [ $LEN -lt 15 ]; then
                      echo "ComputerID "$adcomputerid " has 15 characters or less and is therefore suitable for AD-Binding. It is $adcomputerid"
                      computeridtmp=$adcomputerid
              else
                      echo "ComputerID "$adcomputerid " has 16 or more characters and needs to be modified for AD-Binding."
                        echo "Removing any -"
                      computeridtmp=${adcomputerid//-/}
                                  LEN=$(echo ${#computeridtmp})
                                  if [ $LEN -lt 15 ]; then
                                            echo "ComputerID "$computeridtmp" has now 15 characters or less and is therefore suitable for AD-Binding."
                                  else
                                            echo "Only using the last 15 characters of the Computer name to be able to bind to AD."
                                            computeridtmp=${computeridtmp:(-15)}
                                  fi
                      echo "Cropped Computername to "$computeridtmp
              fi
    else
        computeridtmp=${check4ADacct//$/}
        echo "Found existing AD Account previously, attempting to recreate in the OU: "$computeridtmp
    fi
    echo ""
    # Bind to AD
    echo "Binding to AD-Domain "$domain" with computerid "$computeridtmp
    dsconfigad -f -add "$domain" -username "$udn" -password "$password" -ou "$ou" -computer "$computeridtmp"
    echo ""
    echo "Setting the Advanced AD Plugin options"
    # Configure advanced AD plugin options
    if [ "$admingroups" = "" ]
    then
              dsconfigad -nogroups
    else
              dsconfigad -groups "$admingroups"
    fi
    dsconfigad -alldomains "$alldomains"
    dsconfigad -localhome "$localhome"
    dsconfigad -protocol "$protocol"
    dsconfigad -mobile "$mobile"
    dsconfigad -mobileconfirm "$mobileconfirm"
    dsconfigad -useuncpath "$useuncpath"
    dsconfigad -shell "$user_shell"
    dsconfigad "$preferred"
    dsconfigad -packetsign "$packetsign" -packetencrypt "$packetencrypt" -passinterval "$passinterval"
    dsconfigad -namespace "$namespace"
    sleep 5
    echo ""
    echo ""
    # Add the OD & AD node to the search path
    if [ "$alldomains" = "enable" ]
    then
              csp="/Active Directory/$domainname/All Domains"
    else
              csp="/Active Directory/$domainname"
    fi
    echo "Finished AD Binding."
    echo "Adding Domain /LDAPv3/"$oddomain" and "$csp" to Search Path"
    dscl /Search -create / SearchPolicy CSPSearchPath
    dscl /Search/Contacts -create / SearchPolicy CSPSearchPath
    echo "Adding OD.."
    dscl /Search -append / CSPSearchPath /LDAPv3/"$oddomain"
    dscl /Search/Contacts -append / CSPSearchPath /LDAPv3/"$oddomain"
    echo "Adding AD.."
    #Adding all Domains first to improve reliability under 10.7
    if [ "$alldomains" != "enable" ]
    then
        cspadall="/Active Directory/$domainname/All Domains"
        dscl /Search/Contacts -append / CSPSearchPath "$cspadall"
        dscl /Search -append / CSPSearchPath "$cspadall"
    fi
    dscl /Search/Contacts -append / CSPSearchPath "$csp"
    dscl /Search -append / CSPSearchPath "$csp"
    echo "Finished Updating Search Paths."
    echo ""
    echo ""
    # Restart DirectoryService (necessary to reload AD plugin activation settings)
    killall opendirectoryd
    # Destroy the login hook (or change it)
    if [ "${newLoginHook}" == "" ]
    then
              defaults delete /var/root/Library/Preferences/com.apple.loginwindow LoginHook
    else
              defaults write /var/root/Library/Preferences/com.apple.loginwindow LoginHook $newLoginHook
    fi
    sleep 5
    # Customizing the login-Window
    #defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo DSStatus
    #defaults write /Library/Preferences/com.apple.loginwindow showInputMenu -bool TRUE
    #defaults write /Library/Preferences/com.apple.loginwindow SHOWFULLNAME -bool TRUE
    # This works in a pinch if the above code does not
    #defaults write /Library/Preferences/DirectoryService/SearchNodeConfig "Search Node Custom Path Array" -array "/Active Directory/All Domains"
    #defaults write /Library/Preferences/DirectoryService/SearchNodeConfig "Search Policy" -int 3
    #plutil -convert xml1 /Library/Preferences/DirectoryService/SearchNodeConfig.plist
    #killall opendirectoryd
    # Disable autologin
    defaults delete /Library/Preferences/com.apple.loginwindow autoLoginUser
    srm /etc/kcpassword
    echo ""
    echo ""
    echo ""
    echo "Now bound to OD Domain:"
    dscl localhost -list /LDAPv3
    echo "With Search Path entries:"
    dscl /Search -read / CSPSearchPath | grep /LDAP
    echo "Now bound to AD Domain:"
    dscl localhost -list "/Active Directory"
    echo "With Search Path entries:"
    dscl /Search -read / CSPSearchPath | grep /Active
    exit 0                    ## Success
    exit 1                    ## Failure
    Any inputs, questions and improvement suggestions are, of course, most welcome!
    Cheers
    See

    Hi everyone
    I'm reposting this in the right thread. I've written a Directory Binding Script for 10.6 and ported it now to 10.7 as among the things that have changed in the upgraded version is a refurbished directory binding enviroment.
    The original thread can be found here: https://discussions.apple.com/thread/3090068. The script is applicable for clients as well and simplifies the binding process considerably.
    Be aware that the reformatted script here contains some faulty line breaks. So you'll have to correct them in a proper text editor.
    #!/bin/sh
    #Uncomment the following line to abort the script on errors
    #trap exit ERR
    ## Script to automate OD and AD Binding of Mac OS X 10.7 Servers
    ## Script written by Marc Horat, URZ Basel, 11.6.2010
    ## Updated: 12.08.2011
    # With the use of the following sources as inspiration:
    # http://www.howtomac.co.uk/?p=247
    #Created by Ross Hamilton
    #Clock restart / Remove existing settings
    #Join to Open Directory and Active Directory
    # Bombich's AD-Bind Script:
    # This script binds to AD and configures advanced options of the AD plugin
    # As this scripts contains a password, be sure to take appropriate security
    # precautions
    # A good way to run this script is to set it as a login hook on your master machine
    # Because it only needs to be run once, the last thing this script does is to delete
    # itself. If you have another login script that you typically run, include the
    # script on your master machine, and indicate its path in the "newLoginScript"
    # variable.
    # If running this as a one-time login hook to bind to AD after imaging,
    # be sure to enable auto-login (for any local user) before creating your master image
    #################CONFIGURATION##########################
    #OD
    # These variables need to be configured for your env
    odAdmin="YOURODADMIN" #enter your OD admin name between the quotes
    odPassword="YOURODPW"  # Enter your OD admin password between the quotes
    oddomain="YOURODDOMAIN" # FQDN of your OD domain
    computerGroup="YOURNEWODCOMPGROUP"  # Add appropriate computer group you want machines to be added to, case sensitive
    oldComputerGroup="YOUROLDODCOMPGROUP" # If the Computer is in a Group already
    #AD
    # Standard parameters
    domain="YOURADDOMAIN"                              # fully qualified DNS name of Active Directory Domain
    domainname="YOURADDOMAINNAME"                    #Name of the Domain as specified in the search paths
    udn="YOURADADMIN"                              # username of a privileged network user
    password="YOURADPW"                                                  # password of a privileged network user
    ou="OU=YOUR,OU=OU,OU=URZ,OU=IN,DC=YOUR,DC=AD,DC=DOMAIN"                    # Distinguished name of container for the computer E.G. OU=Macs,OU=Computers,DC=AD,DC=DOMAIN,DC=CH
    # Advanced options AD Plugin
    alldomains="disable"                              # 'enable' or 'disable' automatic multi-domain authentication
    localhome="disable"                              # 'enable' or 'disable' force home directory to local drive
    protocol="smb"                                        # 'afp', 'smb' or 'nfs' (since 10.7) change how home is mounted from server
    mobile="enable"                              # 'enable' or 'disable' mobile account support for offline logon
    mobileconfirm="enable"                    # 'enable' or 'disable' warn the user that a mobile acct will be created
    useuncpath="enable"                              # 'enable' or 'disable' use AD SMBHome attribute to determine the home dir
    user_shell="/bin/bash"                    # e.g., /bin/bash or "none"
    preferred="-preferred $domain"          # Use the specified server for all Directory lookups and authentication
    # (e.g. "-nopreferred" or "-preferred ad.server.edu")
    admingroups="$domainname\YOURADADMINGROUP" # These comma-separated AD groups may administer the machine (e.g. "" or "APPLE\macadmins")
    packetsign="allow"                              # allow | disable | require
    packetencrypt="allow"                    # allow | disable | require
    passinterval="14"                              # number of days
    namespace="domain"                              # forest | domain
    # Login hook setting -- specify the path to a login hook that you want to run instead of this script
    newLoginHook=""                    # e.g., "/Library/Management/login.sh"
    ################################# End of configuration
    ############ Begin of Script
    # Host-specific parameters
    # computerid should be set dynamically, this value must be machine-specific
    # This value may be restricted to 19 characters! The only error you'll receive upon entering
    # an invalid computer id is to the effect of not having appropriate privileges to perform the requested operation
    #computerid=`/sbin/ifconfig en0 | awk '/ether/ { gsub(":", ""); print $2 }'` # MAC Address
    #computerid=`hostname | sed 's/.unibas.ch//'`
    #computerid=`/usr/sbin/scutil --get LocalHostName | cut -c 1-19` # Assure that this will produce unique names!
    #computerid=`/usr/sbin/scutil --get LocalHostName`
    computerid=`scutil --get ComputerName`
    adcomputerid=`echo "$computerid" | tr [:lower:] [:upper:]`
    # These variables probably don't need to be changed
    # Determing if any directory binding exists
    nicAddress=`ifconfig en0 | grep ether | awk '{print $2}'`
    if dscl localhost -list /LDAPv3 | grep . > /dev/null
    then
              check4ODtmp=`dscl localhost -list /LDAPv3 | grep -n 1 | sed 's/1://' | sed 's/2://'`
              check4OD=${check4ODtmp//[[:space:]]/}
              echo "Found LDAP: "$check4ODtmp
              check4ODaccttmp=`dscl /LDAPv3/"$check4OD" -read Computers/"$computerid" RealName | cut -c 11-`
              check4ODacct=${check4ODaccttmp//[[:space:]]/}
              echo "Found LDAP-Computer-Account: "$check4ODacct
    else
              check4OD=""
              check4ODacct=""
              echo "No bound LDAP Server found"
    fi
    if [ $oldComputerGroup != "" ] && dscl localhost -list /LDAPv3 | grep . > /dev/null
    then
              check4ODgroupMembershiptmp=`dscl /LDAPv3/"$check4OD" -read ComputerGroups/"$oldComputerGroup" | grep "$computerid"`
              check4ODgroupMembership=$check4ODgroupMembershiptmp
              echo "LDAP Group Membership in Group: "$oldComputerGroup
    else
              check4ODgroupMembership=""
              echo "No LDAP Group Membership defined or not bound to a server"
    fi
    if dscl localhost -list "/Active Directory" | grep $domainname > /dev/null
    then
              check4ADtmp=`dsconfigad -show | grep "Active Directory Domain" | sed 's/Active Directory Domain//'  | sed 's/=//'`
              check4AD=${check4ADtmp//[[:space:]]/}
              echo "Found AD: "$check4AD
              check4ADaccttmp=`dsconfigad -show | grep "Computer Account" | sed 's/Computer Account//' | sed 's/=//'`
              check4ADacct=${check4ADaccttmp//[[:space:]]/}
              echo "Found AD-Account: "$check4ADacct
    else
              check4AD=""
              check4ADacct=""
              echo "No AD-Account found"
    fi
    osversionlong=`sw_vers -productVersion`
    osvers=${osversionlong:3:1}
    #Time Sync
    #Restart ntpdate
    StartService ()
    if [ "${TIMESYNC:=-YES-}" = "-YES-" ] && ! GetPID ntpd > /dev/null; then
              CheckForNetwork
    if [ -f /var/run/NetworkTime.StartupItem -o "${NETWORKUP}" = "-NO-" ]; then exit; fi
              touch /var/run/NetworkTime.StartupItem
              echo "Starting network time synchronization"
    # Synchronize our clock to the network’s time,
    # then fire off ntpd to keep the clock in sync.
              ntpdate -bvs
              ntpd -f /var/run/ntp.drift -p /var/run/ntpd.pid
    fi
    echo ""
    echo ""
    sleep 5
    #### Removing any existing directory bindings
    #Clear OD Computer Account and delete entry from Computer group
    if dscl localhost -list /LDAPv3 | grep . > /dev/null
    then
              echo "This computer is bound to the following Open Directory Services:"
              dscl localhost -list /LDAPv3
              echo "With the Search Path entries:"
              dscl /Search -read / CSPSearchPath | grep /LDAP
              sleep 5
              if [ "${check4ODacct}" == "${computerid}" ]
              then
                        echo "This machine already has a computer account on $oddomain."
                        # Set the GUID
                        GUID="$(dscl /LDAPv3/$oddomain -read /Computers/${computerid} GeneratedUID | awk '{ print $2 }')"
                        echo "Found GUID: "$GUID
                        if [ "$oldComputerGroup" != "" ] && [ "$check4ODgroupMembership" != "" ]
                        then
                                  echo "Removing entry from group $oldComputerGroup"
                                  dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$check4OD" -delete /ComputerGroups/"$oldComputerGroup" GroupMembership "${computerid}"
                                  dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$check4OD" -delete /ComputerGroups/"$oldComputerGroup" GroupMembers "${GUID}"
                                  dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$check4OD" -delete /ComputerLists/"$oldComputerGroup" Computers "${computerid}"
                        fi
                        echo "Removing Computer entry $computerid in OD"
                        dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$check4OD" -delete /Computers/"${computerid}"
              fi
              #List existing Directories
              echo "Removing OD-Binding to "$check4OD
              dsconfigldap -r "$check4OD"
              echo "Removing Search Path entries"
              dscl /Search -delete / CSPSearchPath /LDAPv3/"$check4OD"
              dscl /Search/Contacts -delete / CSPSearchPath /LDAPv3/"$check4OD"
              dscl /Search -delete / CSPSearchPath /LDAPv3/"$check4OD"
              sleep 5
    else
              echo "No LDAP or OD Binding present.";
    fi
    echo ""
    # Check a second time in order to delete any remaining LDAP-Bindings
    echo "Scanning for further LDAP servers"
    if dscl localhost -list /LDAPv3 | grep . > /dev/null
    then
              echo "Found:"
              dscl localhost -list /LDAPv3
              echo "Removing OD-Binding to "$check4ODtmp
              dsconfigldap -r "$check4ODtmp"
              dscl /Search -delete / CSPSearchPath /LDAPv3/"$check4ODtmp"
              dscl /Search/Contacts -delete / CSPSearchPath /LDAPv3/"$check4ODtmp"
              dscl /Search -delete / CSPSearchPath /LDAPv3/"$check4ODtmp"
              sleep 5
    else
              echo "No further LDAP or OD Binding present."
    fi
    echo ""
    echo ""
    #Remove the Active Directory binding
    if [ "$check4AD" != "" ]
    then
              echo "This computer is bound to the following Active Directory Services:"
              dscl localhost -list "/Active Directory"
              echo "With the Search Path entries:"
              dscl /Search -read / CSPSearchPath | grep /Active
              sleep 5
              echo "Removing any existing AD-Binding to "$check4AD
        dsconfigad -f -remove -username "$udn" -password "$password"
        echo "Removing Search Path entries"
              if [ "$preferred" != "-nopreferred" ]
              then
                        dscl /Search -delete / CSPSearchPath /Active Directory/"$domainname"
                        dscl /Search/Contacts -delete / CSPSearchPath /Active Directory/"$domainname"
                        dscl /Search -delete / CSPSearchPath /Active Directory/"$domainname"
              fi
              dscl /Search -delete / CSPSearchPath "/Active Directory/$domainname/All Domains"
              dscl /Search/Contacts -delete / CSPSearchPath "/Active Directory/$domainname/All Domains"
    #remove search path entries from 10.6
        if dscl /Search -read / CSPSearchPath | grep /Active > /dev/null
        then
            dscl /Search -delete / CSPSearchPath "/Active Directory/$domainname/$domain"
            dscl /Search/Contacts -delete / CSPSearchPath "/Active Directory/$domainname/$domain"
        fi
              sleep 5
    else
              echo "No Active Directory Binding present."
    fi
    echo ""
    #Remove Existing Directory Services Config
    echo "Removing existing DS Config"
    if [ -d "/Library/Preferences/edu.mit.Kerberos" ]
    then
              rm -R /Library/Preferences/edu.mit.Kerberos
    fi
    if [ -d "/etc/krb5.keytab" ]
    then
              rm -R /etc/krb5.keytab
    fi
    # Clean up the DirectoryService configuration files
    rm -Rfv /Library/Preferences/DirectoryService/*
    #OD
    echo ""
    echo ""
    echo "Binding to OD-Damin "$oddomain
    sleep 5
    dsconfigldap -v -a "$oddomain" -n "$oddomain" -c "$computerid"
    echo "Killing opendirectoryd"
    killall opendirectoryd
    sleep 5
    echo "Adding computer account $computerid to /LDAPv3/${oddomain} on $oddomain"
    dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$oddomain" -create /Computers/"$computerid" ENetAddress "$nicAddress"
    dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$oddomain" -merge /Computers/"$computerid" RealName "$computerid"
    # Set the GUID
    GUID="$(dscl /LDAPv3/$oddomain -read /Computers/${computerid} GeneratedUID | awk '{ print $2 }')"
    # Add computer to ComputerList and ComputerGroup
    if [ $computerGroup != "" ]
    then
              echo "Adding computer $computerid to OD group $computerGroup on $oddomain"
              dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$oddomain" -merge /ComputerLists/"$computerGroup" apple-computers "$computerid"
              dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$oddomain" -merge /ComputerGroups/"$computerGroup" apple-group-memberguid "${GUID}"
              dscl -u "${odAdmin}" -P "${odPassword}" /LDAPv3/"$oddomain" -merge /ComputerGroups/"$computerGroup" memberUid "$computerid"
    fi
    echo "Finished OD Binding."
    sleep 5 # Give DS a chance to catch up
    echo ""
    echo ""
    echo "Performing the AD Binding"
    #AD
    # Activate the AD plugin
    defaults write /Library/Preferences/DirectoryService/DirectoryService "Active Directory" "Active"
    plutil -convert xml1 /Library/Preferences/DirectoryService/DirectoryService.plist
    #Use the existing AD-Computername or generate a new one
    computeridtmp="default"
    if [ "$check4ADacct" == "" ]
    then
              LEN=$(echo ${#adcomputerid})
              if [ $LEN -lt 15 ]; then
                      echo "ComputerID "$adcomputerid " has 15 characters or less and is therefore suitable for AD-Binding. It is $adcomputerid"
                      computeridtmp=$adcomputerid
              else
                      echo "ComputerID "$adcomputerid " has 16 or more characters and needs to be modified for AD-Binding."
                        echo "Removing any -"
                      computeridtmp=${adcomputerid//-/}
                                  LEN=$(echo ${#computeridtmp})
                                  if [ $LEN -lt 15 ]; then
                                            echo "ComputerID "$computeridtmp" has now 15 characters or less and is therefore suitable for AD-Binding."
                                  else
                                            echo "Only using the last 15 characters of the Computer name to be able to bind to AD."
                                            computeridtmp=${computeridtmp:(-15)}
                                  fi
                      echo "Cropped Computername to "$computeridtmp
              fi
    else
        computeridtmp=${check4ADacct//$/}
        echo "Found existing AD Account previously, attempting to recreate in the OU: "$computeridtmp
    fi
    echo ""
    # Bind to AD
    echo "Binding to AD-Domain "$domain" with computerid "$computeridtmp
    dsconfigad -f -add "$domain" -username "$udn" -password "$password" -ou "$ou" -computer "$computeridtmp"
    echo ""
    echo "Setting the Advanced AD Plugin options"
    # Configure advanced AD plugin options
    if [ "$admingroups" = "" ]
    then
              dsconfigad -nogroups
    else
              dsconfigad -groups "$admingroups"
    fi
    dsconfigad -alldomains "$alldomains"
    dsconfigad -localhome "$localhome"
    dsconfigad -protocol "$protocol"
    dsconfigad -mobile "$mobile"
    dsconfigad -mobileconfirm "$mobileconfirm"
    dsconfigad -useuncpath "$useuncpath"
    dsconfigad -shell "$user_shell"
    dsconfigad "$preferred"
    dsconfigad -packetsign "$packetsign" -packetencrypt "$packetencrypt" -passinterval "$passinterval"
    dsconfigad -namespace "$namespace"
    sleep 5
    echo ""
    echo ""
    # Add the OD & AD node to the search path
    if [ "$alldomains" = "enable" ]
    then
              csp="/Active Directory/$domainname/All Domains"
    else
              csp="/Active Directory/$domainname"
    fi
    echo "Finished AD Binding."
    echo "Adding Domain /LDAPv3/"$oddomain" and "$csp" to Search Path"
    dscl /Search -create / SearchPolicy CSPSearchPath
    dscl /Search/Contacts -create / SearchPolicy CSPSearchPath
    echo "Adding OD.."
    dscl /Search -append / CSPSearchPath /LDAPv3/"$oddomain"
    dscl /Search/Contacts -append / CSPSearchPath /LDAPv3/"$oddomain"
    echo "Adding AD.."
    #Adding all Domains first to improve reliability under 10.7
    if [ "$alldomains" != "enable" ]
    then
        cspadall="/Active Directory/$domainname/All Domains"
        dscl /Search/Contacts -append / CSPSearchPath "$cspadall"
        dscl /Search -append / CSPSearchPath "$cspadall"
    fi
    dscl /Search/Contacts -append / CSPSearchPath "$csp"
    dscl /Search -append / CSPSearchPath "$csp"
    echo "Finished Updating Search Paths."
    echo ""
    echo ""
    # Restart DirectoryService (necessary to reload AD plugin activation settings)
    killall opendirectoryd
    # Destroy the login hook (or change it)
    if [ "${newLoginHook}" == "" ]
    then
              defaults delete /var/root/Library/Preferences/com.apple.loginwindow LoginHook
    else
              defaults write /var/root/Library/Preferences/com.apple.loginwindow LoginHook $newLoginHook
    fi
    sleep 5
    # Customizing the login-Window
    #defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo DSStatus
    #defaults write /Library/Preferences/com.apple.loginwindow showInputMenu -bool TRUE
    #defaults write /Library/Preferences/com.apple.loginwindow SHOWFULLNAME -bool TRUE
    # This works in a pinch if the above code does not
    #defaults write /Library/Preferences/DirectoryService/SearchNodeConfig "Search Node Custom Path Array" -array "/Active Directory/All Domains"
    #defaults write /Library/Preferences/DirectoryService/SearchNodeConfig "Search Policy" -int 3
    #plutil -convert xml1 /Library/Preferences/DirectoryService/SearchNodeConfig.plist
    #killall opendirectoryd
    # Disable autologin
    defaults delete /Library/Preferences/com.apple.loginwindow autoLoginUser
    srm /etc/kcpassword
    echo ""
    echo ""
    echo ""
    echo "Now bound to OD Domain:"
    dscl localhost -list /LDAPv3
    echo "With Search Path entries:"
    dscl /Search -read / CSPSearchPath | grep /LDAP
    echo "Now bound to AD Domain:"
    dscl localhost -list "/Active Directory"
    echo "With Search Path entries:"
    dscl /Search -read / CSPSearchPath | grep /Active
    exit 0                    ## Success
    exit 1                    ## Failure
    Any inputs, questions and improvement suggestions are, of course, most welcome!
    Cheers
    See

  • How can a JVM terminate with an exit code of 141 and no other diagnostics?

    Hello,
    We are encountering a JVM process that dies with little explanation other than an exit code of 141. No hotspot error file (hs_err_*) or crash dump.  To date, the process runs anywhere from 30 minutes to 8 days before the problem occurs. The last application log entry is always the report of a lost SSL connection, the result of an thrown SSLException.  (The exception itself is unavailable at this time – the JVM dies before it is logged -- working on that.)
    How can a JVM produce an exit code of 141, and nothing else?  Can anyone suggest ideas for capturing additional diagnostic information?  Any help would be greatly appreciated!  Environment and efforts to date are described below.
    Thanks,
    -KK
    Host machine: 8x Xeon server with 256GB memory, RHEL 6 (or RHEL 5.5) 64-bit
    Java: Oracle Java SE 7u21 (or 6u26)
    java version "1.7.0_21"
    Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
    Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
    JVM arguments:
    -XX:+UseConcMarkSweepGC
    -XX:+CMSIncrementalMode
    -XX:+CMSClassUnloadingEnabled
    -XX:MaxPermSize=256m
    -XX:NewSize=64m
    -Xms128m
    -Xmx1037959168
    -Djava.awt.headless=true
    -Djava.security.egd=file:///dev/./urandom
    Diagnostics attempted to date:
    LD_PRELOAD=libjsig.so.   A modified version of libjsig.so was created to report all signal handler registrations and to report SIGPIPE signals received.  (Exit code 141 could be interpreted as 128+SIGPIPE(13).)  No JNI libraries are registering any signal handlers, and no SIGPIPE signal is reported by the library for the duration of the JVM run.  Calls to ::exit() are also intercepted and reported.  No call to exit() is reported.
    Inspect /var/log/messages for any indication that the OS killed the process, e.g. via the Out Of Memory (OOM) Killer.  Nothing found.
    Set ‘ulimit –c unlimited’, in case the default limit of 0 (zero) was preventing a core file from being written.  Still no core dump.
    ‘top’ reports the VIRT size of the process can grow to 20GB or more in a matter of hours, which is unusual compared to other JVM processes.  The RES (resident set size) does not grow beyond about 375MB, however, which is an considered normal.
    This JVM process creates many short-lived Thread objects by way of a thread pool, averaging 1 thread every 2 seconds, and these objects end up referenced only by a Weak reference.   The CMS collector seems lazy about collecting these, and upwards of 2000 Thread objects have been seen (in heap dumps) held only by Weak references.  (The Java heap averages about 100MB, so the collector is not under any pressure.) However, a forced collection (via jconsole) cleans out the Thread objects as expected.  Any relationship of this to the VIRT size or the JVM disappearance, however, cannot be established.
    The process also uses NIO and direct buffers, and maintains a DirectByteBuffer cache. There is some DirectByteBuffer churn. MBeans report stats like:
    Direct buffer pool: allocated=669 (20,824,064 bytes), released=665 (20,725,760), active=4 (98,304)  [note: equals 2x 32K buffers and 2x 16K buffers]
    java.nio.BufferPool > direct: Count=18, MemoryUsed=1343568, TotalCapacity=1343568
    These numbers appear normal and also do not seem to correlate with the VIRT size or the JVM disappearance.

    True, but the JNI call would still be reported by the LD_PRELOAD intercept, unless the native code could somehow circumvent that.  Using a test similar to GoodbyeWorld (shown below), I verified that the JNI call to exit() is reported.  In the failure case, no call to exit() is reported.
    Can an OS (or a manual) 'kill' specify an exit code?  Where could "141" be coming from?
    Thanks,
    -K2
    === GoodbyeWorldFromJNI.java ===
    package com.attachmate.test;
    public class GoodbyeWorldFromJNI
        public static final String LIBRARY_NAME = "goodbye";
        static {
            try {
                System.loadLibrary(LIBRARY_NAME);
            } catch (UnsatisfiedLinkError error) {
                System.err.println("Failed to load " + System.mapLibraryName(LIBRARY_NAME));
        private static native void callExit(int exitCode);
        public static void main(String[] args) {
            callExit(141);
    === goodbye.c ===
    #include <stdlib.h>
    #include "goodbye.h"  // javah generated header file
    JNIEXPORT void JNICALL Java_com_attachmate_test_GoodbyeWorldFromJNI_callExit
      (JNIEnv *env, jclass theClass, jint exitCode)
        exit(exitCode);
    === script.sh ===
    #!/bin/bash -v
    uname -a
    export PATH=/opt/jre1.7.0_25/bin:$PATH
    java -version
    pwd
    LD_PRELOAD=./lib/linux-amd64/libjsigdebug.so java -classpath classes -Djava.library.path=lib/linux-amd64 com.attachmate.test.GoodbyeWorldFromJNI > stdout.txt
    echo $?
    tail stdout.txt
    === script output ===
    [keithk@keithk-RHEL5-dev goodbyeJNI]$ ./script.sh
    #!/bin/bash -v
    uname -a
    Linux keithk-RHEL5-dev 2.6.18-164.2.1.el5 #1 SMP Mon Sep 21 04:37:42 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
    export PATH=/opt/jre1.7.0_25/bin:$PATH
    java -version
    java version "1.7.0_25"
    Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
    Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
    pwd
    /tmp/goodbyeJNI
    LD_PRELOAD=./lib/linux-amd64/libjsigdebug.so java -classpath classes -Djava.library.path=lib/linux-amd64 com.attachmate.test.GoodbyeWorldFromJNI > stdout.txt
    echo $?
    141
    tail stdout.txt
    JSIG: exit(141) called
    JSIG: Call stack has 4 frames:
    JSIG: ./lib/linux-amd64/libjsigdebug.so [0x2b07dc1bdc2f]
    JSIG: ./lib/linux-amd64/libjsigdebug.so(exit+0x29) [0x2b07dc1bea41]
    JSIG: /tmp/goodbyeJNI/lib/linux-amd64/libgoodbye.so [0x2aaab3e82547]
    JSIG: [0x2aaaab366d8e]       
    === ===

  • Looping through SQL statements in shell script

    Hello members,
    I'm working on the Solaris environment and the DB i'm using is Oracle 10g. Skeleton of what I'm attempting;
    Write a ksh script to perform the following. I have no idea how to include my sql query within a shell script and loop through the statements. Have therefore given a jist of what I'm attempting, below.
    1. Copy file to be processed (one file at a time, from a list of 10 files in the folder ).
    for i in *
               do
               cp $i /home/temp[/CODE]2 . Create a snapshot(n) table : Initialize n = 1 -- -- To create my snapshot table and inserts records in SQL
    create table test insert account_no, balance from records_all;3. Checking if the table has been created successfully:
    select count(*) from snapshot1 -- query out the number of records in the table -- always fixed, say at 400000
    if( select count(*) from snapshot(n) = 400000 )
    echo " table creation successful.. proceed to the next step "
    else
    echo " problem creating table, exiting the script .. "  4. If table creation is successful,
    echo " select max(value) from results_all " -- printing the max value to console
    5. Process my files using the following jobs:
    ./runscript.ksh - READ -i $m ( m - initial value 001 )
    ./runscript.ksh - WRITE -i $m ( m - initial value 001 -- same as READ process_id )
    -- increment m by 1
    6. Wait for success log
    tail -f log($m)* | -egrep "^SUCCESS"7. looping to step1 to :
    Copy file 2 to temp folder;
    create snapshot(n+1) table
    Exit when all the files have been copied for processing.
    done -- End of Step 1
    Pointers on getting me moving will be very valuable.
    thanks,
    Kris

    Hi,
    Are you inserting the data from file or from some table.
    If it is from file, I suggest sql loader would be better, I suppose.
    If it is from table, then something like this
    for i in *
               do
    sqlplus username/password@db_name<<EOF
                create table test select * account_no, balance from records_all;
    EOF
    exit
    doneAnurag

  • Triggering "exit" event of a drop-down list in all instances of a table row

    I have a drop-down list in a table row with multiple instances that performs a calculation on the exit event. This calculation draws information from 2 other dropdown lists contained above in non-repeating rows of the same table.
    The desired behavior is: should the user change their choices above, all instances of the drop-down list below would perform the "Exit" event script  accessing the new values above.
    My script is:
    RowOptionalCoverage.DdlCoverageType.execEvent("exit");     this works, sort of
    It only updates the first instance of RowOptionalCoverage and none of the subsequent instances. The user can "Tab" through the instances and trigger the Exit event for each instance, but this is not a reasonable solution.
    I have tried using the resolveNodes method without success. I understand, using the resolveNodes method may be necessary when referencing multiple instances of an object:
    this.resolveNodes("RowOptionalCoverage[*].DdlCoverageType[*]").execEvent("exit");     doesn't work
    xfa.resolveNodes("RowOptionalCoverage[*].DdlCoverageType[*]").execEvent("exit");      doesn't work
    No doubt, I must be using the resolveNodes incorrectly or missing something? Probably something simple.
    Any advice is greatly appreciated.
    Stephen

    PERFECT!!! Works right out of the box!
    This has opened my eyes to the essential nature of loops. My form is very large and complex and functions correctly, Yet the coding is lacking in sophistication--no loops, functions, fragments or other code efficiencies. I am teaching myself (with the help here) and I have skipped learning and using some techniques when I could things to work using the  limited skill set I have.
    Sometimes, I just don't "get it". After I fail a few times, I skip it and try something else. Functions are a great example. I could utilize a bunch of these if I could only write one that works. It is frustrating. If I got one to work, I know could write a ton of them. But, there is some essential part of functions I am missing that's preventing me from having my first success with them. (I think it has to do with not understanding arguments completely).
    Anyway, I am overjoyed with the solution you provided and I understand it well enough to be able to use again in other situations.
    Thanks again!
    Stephen

  • How to use stored script from with Grid Control 10gR2

    HI
    My backup method uses a stored script in the recovery catalog that is separated from Grid Control's repository database.
    In Scheduled Backup, there is no way to connect to recovery catalog; let alone use stored script. Is that true?
    Thanks,
    Kevin

    it works, here is a test case , I use this functionality a lot
    $connected from HOST
    rman target / catalog <mycatalog>
    connected to target database: TOPAZ (DBID=3348250252)
    connected to recovery catalog database
    RMAN> create script testbackup
    2> {backup current controlfile;
    3> }
    created script testbackup
    RMAN> run {execute script testbackup;}
    executing script: testbackup
    Starting backup at 12-JUN-07
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=217 devtype=DISK
    allocated channel: ORA_DISK_2
    channel ORA_DISK_2: sid=251 devtype=DISK
    allocated channel: ORA_DISK_3
    channel ORA_DISK_3: sid=200 devtype=DISK
    allocated channel: ORA_DISK_4
    channel ORA_DISK_4: sid=337 devtype=DISK
    allocated channel: ORA_DISK_5
    channel ORA_DISK_5: sid=182 devtype=DISK
    channel ORA_DISK_1: starting full datafile backupset
    channel ORA_DISK_1: specifying datafile(s) in backupset
    including current controlfile in backupset
    channel ORA_DISK_1: starting piece 1 at 12-JUN-07
    channel ORA_DISK_1: finished piece 1 at 12-JUN-07
    piece handle=/rman_backup/d_TOPAZ_s_12344_p_1_t_625077001 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
    Finished backup at 12-JUN-07
    Starting Control File and SPFILE Autobackup at 12-JUN-07
    piece handle=/rman_backup/c-3348250252-20070612-06 comment=NONE
    Finished Control File and SPFILE Autobackup at 12-JUN-07
    NOW in grid control I have configured my Recovery catalog settings, check for OS username , that should be owner of oracle home for recover catalog
    I schedule a RMAN backup job with these parameters in script
    {execute script testbackup;}
    Status          Running
         Step ID          203585
         Targets          topaz.ucas.ac.uk
         Started          12-Jun-2007 16:34:56 (UTC+01:00)
         Step Elapsed Time          1 minutes, 37 seconds
         Management Service          stardb1:4889_Management_Service
         TIP      Management Service from which the job step was dispatched.
    Output Log
    Recovery Manager: Release 9.2.0.6.0 - 64bit Production
    Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
    RMAN>
    connected to target database: TOPAZ (DBID=3348250252)
    RMAN>
    connected to recovery catalog database
    RMAN>
    echo set on
    RMAN> {execute script testbackup;}
    2> exit;
    executing script: testbackup
    Starting backup at 12-JUN-07
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=164 devtype=DISK
    allocated channel: ORA_DISK_2
    channel ORA_DISK_2: sid=134 devtype=DISK
    allocated channel: ORA_DISK_3
    channel ORA_DISK_3: sid=22 devtype=DISK
    allocated channel: ORA_DISK_4
    channel ORA_DISK_4: sid=198 devtype=DISK
    allocated channel: ORA_DISK_5
    channel ORA_DISK_5: sid=145 devtype=DISK
    channel ORA_DISK_1: starting full datafile backupset
    channel ORA_DISK_1: specifying datafile(s) in backupset
    including current controlfile in backupset
    channel ORA_DISK_1: starting piece 1 at 12-JUN-07
    channel ORA_DISK_1: finished piece 1 at 12-JUN-07
    piece handle=/rman_backup/d_TOPAZ_s_12346_p_1_t_625077300 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 12-JUN-07
    Starting Control File and SPFILE Autobackup at 12-JUN-07
    piece handle=/rman_backup/c-3348250252-20070612-07 comment=NONE
    Finished Control File and SPFILE Autobackup at 12-JUN-07
    null

  • Share script about ocsg & weblogic

    111setConnEnv.sh :
    #!/bin/bash
    # Set the general domain environment.
    . ~/ocsgCourse/domains/labDomain/bin/setDomainEnv.sh
    # The setDomainEnv script changes the working directory.
    # Use popd to jump back to where we were.
    popd
    # Set general environment variables to be used in all WLST scripts.
    USERNAME="weblogic"
    export USERNAME
    PASSWORD="p4ssw0rd"
    export PASSWORD
    HOSTNAME="localhost"
    export HOSTNAME
    PORT="8001"
    export PORT
    222start_lab_pte.sh :
    #!/bin/sh
    . /opt/ocsg500/wlserver_10.3/common/bin/commEnv.sh
    /opt/ocsg500/ocsg_pds_5.0/pte/run.sh
    333startWebLogic.sh :
    #!/bin/sh
    # WARNING: This file is created by the Configuration Wizard.
    # Any changes to this script may be lost when adding extensions to this configuration.
    DOMAIN_HOME="/home/oracle/ocsgCourse/domains/labDomain"
    ${DOMAIN_HOME}/bin/startWebLogic.sh $*
    444setDomainEnv.sh :
    #!/bin/sh
    # WARNING: This file is created by the Configuration Wizard.
    # Any changes to this script may be lost when adding extensions to this configuration.
    # --- Start Functions ---
    BP=100
    SP=$BP
    pushd()
         if [ -z "$1" ]
         then
              return
         fi
         SP=`expr $SP - 1`
         eval _stack$SP=`pwd`
         cd $1
         return
    popd()
         if [ $SP -eq $BP ]
         then
              return
         fi
         eval cd \${_stack$SP}
         SP=`expr $SP + 1`
         return
    # --- End Functions ---
    # This script is used to setup the needed environment to be able to start Weblogic Server in this domain.
    # This script initializes the following variables before calling commEnv to set other variables:
    # WL_HOME - The BEA home directory of your WebLogic installation.
    # JAVA_VM - The desired Java VM to use. You can set this environment variable before calling
    # this script to switch between Sun or BEA or just have the default be set.
    # JAVA_HOME - Location of the version of Java used to start WebLogic
    # Server. Depends directly on which JAVA_VM value is set by default or by the environment.
    # USER_MEM_ARGS - The variable to override the standard memory arguments
    # passed to java.
    # PRODUCTION_MODE - The variable that determines whether Weblogic Server is started in production mode.
    # DOMAIN_PRODUCTION_MODE
    # - The variable that determines whether the workshop related settings like the debugger,
    # testconsole or iterativedev should be enabled. ONLY settable using the
    # command-line parameter named production
    # NOTE: Specifying the production command-line param will force
    # the server to start in production mode.
    # Other variables used in this script include:
    # SERVER_NAME - Name of the weblogic server.
    # JAVA_OPTIONS - Java command-line options for running the server. (These
    # will be tagged on to the end of the JAVA_VM and
    # MEM_ARGS)
    # For additional information, refer to the WebLogic Server Administration
    # Console Online Help(http://e-docs.bea.com/wls/docs92/ConsoleHelp/startstop.html).
    WL_HOME="/opt/ocsg50/wlserver_10.3"
    export WL_HOME
    BEA_JAVA_HOME="/opt/ocsg50/jrockit_160_17_R28.0.0-677"
    export BEA_JAVA_HOME
    SUN_JAVA_HOME="/opt/ocsg50/jdk160_18"
    export SUN_JAVA_HOME
    WLNG_HOME="/opt/ocsg50/ocsg_5.0"
    export WLNG_HOME
    if [ "${JAVA_VENDOR}" = "BEA" ] ; then
         JAVA_HOME="${BEA_JAVA_HOME}"
         export JAVA_HOME
    else
         if [ "${JAVA_VENDOR}" = "Sun" ] ; then
              JAVA_HOME="${SUN_JAVA_HOME}"
              export JAVA_HOME
         else
    JAVA_VENDOR="Oracle"
              export JAVA_VENDOR
    JAVA_HOME="/opt/ocsg50/jrockit_160_17_R28.0.0-677"
              export JAVA_HOME
         fi
    fi
    # We need to reset the value of JAVA_HOME to get it shortened AND
    # we can not shorten it above because immediate variable expansion will blank it
    JAVA_HOME="${JAVA_HOME}"
    export JAVA_HOME
    SAMPLES_HOME="${WL_HOME}/samples"
    export SAMPLES_HOME
    DOMAIN_HOME="/home/oracle/ocsgCourse/domains/labDomain"
    export DOMAIN_HOME
    LONG_DOMAIN_HOME="/home/oracle/ocsgCourse/domains/labDomain"
    export LONG_DOMAIN_HOME
    if [ "${DEBUG_PORT}" = "" ] ; then
         DEBUG_PORT="8453"
         export DEBUG_PORT
    fi
    if [ "${SERVER_NAME}" = "" ] ; then
    SERVER_NAME="AdminServer"
         export SERVER_NAME
    fi
    # Disable WLS WebService exception trace
    JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.wsee.component.exception=false"
    # Optional ORB configuration
    #JAVA_OPTIONS="${JAVA_OPTIONS} -Dwlng.corba.host=localhost"
    #JAVA_OPTIONS="${JAVA_OPTIONS} -Dwlng.corba.port=10001"
    #JAVA_OPTIONS="${JAVA_OPTIONS} -Dwlng.corba.thread_pool_size=100"
    #JAVA_OPTIONS="${JAVA_OPTIONS} -Dwlng.corba.request_timeout=10000"
    #JAVA_OPTIONS="${JAVA_OPTIONS} -Dwlng.corba.connect_timeout=3000"
    JAVA_OPTIONS="${JAVA_OPTIONS} -Docsg.dir.name=ocsg_5.0"
    JAVA_OPTIONS="${JAVA_OPTIONS} -Dpds.dir.name=ocsg_pds_5.0"
    JAVA_OPTIONS="${JAVA_OPTIONS} -Dmodules.dir.name=modules"
    export JAVA_OPTIONS
    POINTBASE_FLAG="false"
    export POINTBASE_FLAG
    enableHotswapFlag=""
    export enableHotswapFlag
    PRODUCTION_MODE=""
    export PRODUCTION_MODE
    doExitFlag="false"
    export doExitFlag
    verboseLoggingFlag="false"
    export verboseLoggingFlag
    while [ $# -gt 0 ]
    do
         case $1 in
         nodebug)
              debugFlag="false"
              export debugFlag
         production)
              DOMAIN_PRODUCTION_MODE="true"
              export DOMAIN_PRODUCTION_MODE
         notestconsole)
              testConsoleFlag="false"
              export testConsoleFlag
         noiterativedev)
              iterativeDevFlag="false"
              export iterativeDevFlag
         noLogErrorsToConsole)
              logErrorsToConsoleFlag="false"
              export logErrorsToConsoleFlag
         nopointbase)
              POINTBASE_FLAG="false"
              export POINTBASE_FLAG
         doExit)
              doExitFlag="true"
              export doExitFlag
         noExit)
              doExitFlag="false"          export doExitFlag
         verbose)
              verboseLoggingFlag="true"
              export verboseLoggingFlag
         enableHotswap)
              enableHotswapFlag="-javaagent:${WL_HOME}/server/lib/diagnostics-agent.jar"
              export enableHotswapFlag
              PROXY_SETTINGS="${PROXY_SETTINGS} $1"
              export PROXY_SETTINGS
         esac
         shift
    done
    if [ "${DOMAIN_PRODUCTION_MODE}" = "true" ] ; then
         PRODUCTION_MODE="${DOMAIN_PRODUCTION_MODE}"
         export PRODUCTION_MODE
    fi
    if [ "${PRODUCTION_MODE}" = "true" ] ; then
         debugFlag="false"
         export debugFlag
         testConsoleFlag="false"
         export testConsoleFlag
         iterativeDevFlag="false"
         export iterativeDevFlag
    fi
    # If you want to override the default Patch Classpath, Library Path and Path for this domain,
    # Please uncomment the following lines and add a valid value for the environment variables
    # set PATCH_CLASSPATH=[myPatchClasspath] (windows)
    # set PATCH_LIBPATH=[myPatchLibpath] (windows)
    # set PATCH_PATH=[myPatchPath] (windows)
    # PATCH_CLASSPATH=[myPatchClasspath] (unix)
    # PATCH_LIBPATH=[myPatchLibpath] (unix)
    # PATCH_PATH=[myPatchPath] (unix)
    . ${WL_HOME}/common/bin/commEnv.sh
    #Add WLNG store schema directory to WLS extension directories
    WEBLOGIC_EXTENSION_DIRS=${WEBLOGIC_EXTENSION_DIRS}${CLASSPATHSEP}${DOMAIN_HOME}/config/store_schema
    WLS_HOME="${WL_HOME}/server"
    export WLS_HOME
    WLI_HOME="${WL_HOME}/integration"
    export WLI_HOME
    MEM_ARGS="-Xms256m -Xmx512m"
    if [ "${PRODUCTION_MODE}" = "true" ] ; then
    MEM_ARGS="-Xms512m -Xmx512m"
    if [ "${JAVA_VENDOR}" = "Sun" ] ; then
    MEM_ARGS="${MEM_ARGS} -Xmn256m -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90"
    fi
    else
    if [ "${JAVA_VENDOR}" = "Sun" ] ; then
    MEM_ARGS="${MEM_ARGS} -XX:CompileThreshold=8000 -XX:PermSize=256m"
    fi
    fi
    export MEM_ARGS
    if [ "${JAVA_VENDOR}" = "Sun" ] ; then
         MEM_ARGS="${MEM_ARGS} -XX:MaxPermSize=256m"
         export MEM_ARGS
    fi
    if [ "${JAVA_VENDOR}" = "HP" ] ; then
         MEM_ARGS="${MEM_ARGS} -XX:MaxPermSize=128m"
         export MEM_ARGS
    fi
    # IF USER_MEM_ARGS the environment variable is set, use it to override ALL MEM_ARGS values
    if [ "${USER_MEM_ARGS}" != "" ] ; then
         MEM_ARGS="${USER_MEM_ARGS}"
         export MEM_ARGS
    fi
    JAVA_PROPERTIES="-Dplatform.home=${WL_HOME} -Dwls.home=${WLS_HOME} -Dwli.home=${WLI_HOME}"
    export JAVA_PROPERTIES
    # To use Java Authorization Contract for Containers (JACC) in this domain,
    # please uncomment the following section. If there are multiple machines in
    # your domain, be sure to edit the setDomainEnv in the associated domain on
    # each machine.
    # -Djava.security.manager
    # -Djava.security.policy=location of weblogic.policy
    # -Djavax.security.jacc.policy.provider=weblogic.security.jacc.simpleprovider.SimpleJACCPolicy
    # -Djavax.security.jacc.PolicyConfigurationFactory.provider=weblogic.security.jacc.simpleprovider.PolicyConfigurationFactoryImpl
    # -Dweblogic.security.jacc.RoleMapperFactory.provider=weblogic.security.jacc.simpleprovider.RoleMapperFactoryImpl
    JAVA_PROPERTIES="${JAVA_PROPERTIES} ${EXTRA_JAVA_PROPERTIES}"
    export JAVA_PROPERTIES
    ARDIR="${WL_HOME}/server/lib"
    export ARDIR
    pushd ${LONG_DOMAIN_HOME}
    # Clustering support (edit for your cluster!)
    if [ "${ADMIN_URL}" = "" ] ; then
         # The then part of this block is telling us we are either starting an admin server OR we are non-clustered
         CLUSTER_PROPERTIES="-Dweblogic.management.discover=true"
         export CLUSTER_PROPERTIES
    else
         CLUSTER_PROPERTIES="-Dweblogic.management.discover=false -Dweblogic.management.server=${ADMIN_URL}"
         export CLUSTER_PROPERTIES
    fi
    if [ "${LOG4J_CONFIG_FILE}" != "" ] ; then
         JAVA_PROPERTIES="${JAVA_PROPERTIES} -Dlog4j.configuration=file:${LOG4J_CONFIG_FILE}"
         export JAVA_PROPERTIES
    fi
    JAVA_PROPERTIES="${JAVA_PROPERTIES} ${CLUSTER_PROPERTIES}"
    export JAVA_PROPERTIES
    # Clear the pre_classpath here in case an application template wants to set it before the larger pre_classpath is invoked below
    PRE_CLASSPATH=""
    export PRE_CLASSPATH
    JAVA_DEBUG=""
    export JAVA_DEBUG
    if [ "${debugFlag}" = "true" ] ; then
         JAVA_DEBUG="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=${DEBUG_PORT},server=y,suspend=n -Djava.compiler=NONE"
         export JAVA_DEBUG
         JAVA_OPTIONS="${JAVA_OPTIONS} ${enableHotswapFlag} -ea -da:com.bea... -da:javelin... -da:weblogic... -ea:com.bea.wli... -ea:com.bea.broker... -ea:com.bea.sbconsole..."
         export JAVA_OPTIONS
    else
         JAVA_OPTIONS="${JAVA_OPTIONS} ${enableHotswapFlag} -da"
         export JAVA_OPTIONS
    fi
    if [ ! -d ${JAVA_HOME}/lib ] ; then
         echo "The JRE was not found in directory ${JAVA_HOME}. (JAVA_HOME)"
         echo "Please edit your environment and set the JAVA_HOME"
         echo "variable to point to the root directory of your Java installation."
         popd
         read _val
         exit
    fi
    if [ "${POINTBASE_FLAG}" = "true" ] ; then
         DATABASE_CLASSPATH="${POINTBASE_CLASSPATH}"
         export DATABASE_CLASSPATH
    else
         DATABASE_CLASSPATH="${POINTBASE_CLIENT_CLASSPATH}"
         export DATABASE_CLASSPATH
    fi
    POST_CLASSPATH=""
    export POST_CLASSPATH
    POST_CLASSPATH="${POST_CLASSPATH}${CLASSPATHSEP}${DATABASE_CLASSPATH}${CLASSPATHSEP}${ARDIR}/xqrl.jar"
    export POST_CLASSPATH
    # PROFILING SUPPORT
    JAVA_PROFILE=""
    export JAVA_PROFILE
    SERVER_CLASS="weblogic.Server"
    export SERVER_CLASS
    JAVA_PROPERTIES="${JAVA_PROPERTIES} ${WLP_JAVA_PROPERTIES}"
    export JAVA_PROPERTIES
    JAVA_OPTIONS="${JAVA_OPTIONS} ${JAVA_PROPERTIES} -Dwlw.iterativeDev=${iterativeDevFlag} -Dwlw.testConsole=${testConsoleFlag} -Dwlw.logErrorsToConsole=${logErrorsToConsoleFlag}"
    export JAVA_OPTIONS
    # -- Setup properties so that we can save stdout and stderr to files
    if [ "${WLS_STDOUT_LOG}" != "" ] ; then
         echo "Logging WLS stdout to ${WLS_STDOUT_LOG}"
         JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.Stdout=${WLS_STDOUT_LOG}"
         export JAVA_OPTIONS
    fi
    if [ "${WLS_STDERR_LOG}" != "" ] ; then
         echo "Logging WLS stderr to ${WLS_STDERR_LOG}"
         JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.Stderr=${WLS_STDERR_LOG}"
         export JAVA_OPTIONS
    fi
    # ADD EXTENSIONS TO CLASSPATHS
    if [ "${EXT_PRE_CLASSPATH}" != "" ] ; then
         PRE_CLASSPATH="${EXT_PRE_CLASSPATH}${CLASSPATHSEP}${PRE_CLASSPATH}"
         export PRE_CLASSPATH
    fi
    if [ "${EXT_POST_CLASSPATH}" != "" ] ; then
         POST_CLASSPATH="${POST_CLASSPATH}${CLASSPATHSEP}${EXT_POST_CLASSPATH}"
         export POST_CLASSPATH
    fi
    if [ "${WEBLOGIC_EXTENSION_DIRS}" != "" ] ; then
         JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.ext.dirs=${WEBLOGIC_EXTENSION_DIRS}"
         export JAVA_OPTIONS
    fi
    WLNG_CLASSPATH="${WLNG_HOME}/server/lib/wlng"
    JAVA_OPTIONS="${JAVA_OPTIONS} -Djava.endorsed.dirs=${WLNG_CLASSPATH}/endorsed"
    JAVA_OPTIONS="${JAVA_OPTIONS} -Dwlss.replication=colocated -Dwlss.allow.warm.restart=true"
    JAVA_OPTIONS="${JAVA_OPTIONS} -Dreplica.client.init.retry=5000"
    JAVA_OPTIONS="${JAVA_OPTIONS} -Dreplica.client.timer.poll.allowance=30000"
    JAVA_OPTIONS="${JAVA_OPTIONS} -Dreplica.client.timer.checkup.timeout=30000"
    JAVA_OPTIONS="${JAVA_OPTIONS}"
    export JAVA_OPTIONS
    # SET THE CLASSPATH
    CLASSPATH="${PRE_CLASSPATH}${CLASSPATHSEP}${WEBLOGIC_CLASSPATH}${CLASSPATHSEP}${POST_CLASSPATH}${CLASSPATHSEP}${WLP_POST_CLASSPATH}"
    export CLASSPATH
    JAVA_VM="${JAVA_VM} ${JAVA_DEBUG} ${JAVA_PROFILE}"
    export JAVA_VM
    555startManagedWeblogic.sh :
    #!/bin/sh
    # WARNING: This file is created by the Configuration Wizard.
    # Any changes to this script may be lost when adding extensions to this configuration.
    # --- Start Functions ---
    usage()
         echo "Need to set SERVER_NAME and ADMIN_URL environment variables or specify"
         echo "them in command line:"
         echo "Usage: $1 SERVER_NAME {ADMIN_URL}"
         echo "for example:"
         echo "%1 managedserver1 http://localhost:7001"
    # --- End Functions ---
    # This script is used to start a managed WebLogic Server for the domain in
    # the current working directory. This script can either read in the SERVER_NAME and
    # ADMIN_URL as positional parameters or will read them from environment variables that are
    # set before calling this script. If SERVER_NAME is not sent as a parameter or exists with a value
    # as an environment variable the script will EXIT. If the ADMIN_URL value cannot be determined
    # by reading a parameter or from the environment a default value will be used.
    # For additional information, refer to the WebLogic Server Administration
    # Guide (http://e-docs.bea.com/wls/docs92/adminguide)
    # Set SERVER_NAME to the name of the server you wish to start up.
    DOMAIN_NAME="labDomain"
    ADMIN_URL="http://localhost:8001"
    # Set WLS_USER equal to your system username and WLS_PW equal
    # to your system password for no username and password prompt
    # during server startup. Both are required to bypass the startup
    # prompt.
    WLS_USER=""
    export WLS_USER
    WLS_PW=""
    export WLS_PW
    # Set JAVA_OPTIONS to the java flags you want to pass to the vm. i.e.:
    # set JAVA_OPTIONS=-Dweblogic.attribute=value -Djava.attribute=value
    JAVA_OPTIONS="-Dweblogic.security.SSL.trustedCAKeyStore="/opt/ocsg50/wlserver_10.3/server/lib/cacerts" ${JAVA_OPTIONS}"
    # Set JAVA_VM to the java virtual machine you want to run. For instance:
    # set JAVA_VM=-server
    JAVA_VM=""
    # Set SERVER_NAME and ADMIN_URL, they must by specified before starting
    # a managed server, detailed information can be found at
    # http://e-docs.bea.com/wls/docs92/adminguide
    if [ "$1" = "" ] ; then
         if [ "${SERVER_NAME}" = "" ] ; then
              usage %0
              exit
         fi
    else
         SERVER_NAME="$1"
         shift
    fi
    if [ "$1" = "" ] ; then
         if [ "${ADMIN_URL}" = "" ] ; then
              usage %0
              exit
         fi
    else
         ADMIN_URL="$1"
         shift
    fi
    # Export the admin_url whether the user specified it OR it was sent on the command-line
    ADMIN_URL="${ADMIN_URL}"
    export ADMIN_URL
    SERVER_NAME="${SERVER_NAME}"
    export SERVER_NAME
    DOMAIN_HOME="/home/oracle/ocsgCourse/domains/labDomain"
    if [ "$1" = "" ] ; then
         # Call Weblogic Server with our default params since the user did not specify any other ones
         ${DOMAIN_HOME}/bin/startWebLogic.sh nodebug nopointbase noiterativedev notestconsole
    else
         # Call Weblogic Server with the params the user sent in INSTEAD of the defaults
         ${DOMAIN_HOME}/bin/startWebLogic.sh $1 $2 $3 $4 $5 $6 $7 $8 $9
    fi
    666startPointBaseConsole :
    #!/bin/sh
    # WARNING: This file is created by the Configuration Wizard.
    # Any changes to this script may be lost when adding extensions to this configuration.
    # Call setDomainEnv here to get the correct pointbase port
    DOMAIN_HOME="/home/oracle/ocsgCourse/domains/labDomain"
    . ${DOMAIN_HOME}/bin/setDomainEnv.sh
    ${WL_HOME}/common/bin/startPointBaseConsole.sh -port=${POINTBASE_PORT}
    777startWebLogic.sh :
    #!/bin/sh
    # WARNING: This file is created by the Configuration Wizard.
    # Any changes to this script may be lost when adding extensions to this configuration.
    # --- Start Functions ---
    stopAll()
         # We separate the stop commands into a function so we are able to use the trap command in Unix (calling a function) to stop these services
         if [ "X${ALREADY_STOPPED}" != "X" ] ; then
              exit
         fi
         # STOP POINTBASE (only if we started it)
         if [ "${POINTBASE_FLAG}" = "true" ] ; then
              echo "Stopping PointBase server..."
              ${WL_HOME}/common/bin/stopPointBase.sh -port=${POINTBASE_PORT} -name=${POINTBASE_DBNAME} >"${DOMAIN_HOME}/pointbaseShutdown.log" 2>&1
              echo "PointBase server stopped."
         fi
         ALREADY_STOPPED="true"
         # Restore IP configuration the node manager starts IP Migration
         if [ "${SERVER_IP}" != "" ] ; then
              ${WL_HOME}/common/bin/wlsifconfig.sh -removeif "${IFNAME}" "${SERVER_IP}"
         fi
    # --- End Functions ---
    # This script is used to start WebLogic Server for this domain.
    # To create your own start script for your domain, you can initialize the
    # environment by calling @USERDOMAINHOME/setDomainEnv.
    # setDomainEnv initializes or calls commEnv to initialize the following variables:
    # BEA_HOME - The BEA home directory of your WebLogic installation.
    # JAVA_HOME - Location of the version of Java used to start WebLogic
    # Server.
    # JAVA_VENDOR - Vendor of the JVM (i.e. BEA, HP, IBM, Sun, etc.)
    # PATH - JDK and WebLogic directories are added to system path.
    # WEBLOGIC_CLASSPATH
    # - Classpath needed to start WebLogic Server.
    # PATCH_CLASSPATH - Classpath used for patches
    # PATCH_LIBPATH - Library path used for patches
    # PATCH_PATH - Path used for patches
    # WEBLOGIC_EXTENSION_DIRS - Extension dirs for WebLogic classpath patch
    # JAVA_VM - The java arg specifying the VM to run. (i.e.
    # - server, -hotspot, etc.)
    # USER_MEM_ARGS - The variable to override the standard memory arguments
    # passed to java.
    # PRODUCTION_MODE - The variable that determines whether Weblogic Server is started in production mode.
    # POINTBASE_HOME - Point Base home directory.
    # POINTBASE_CLASSPATH
    # - Classpath needed to start PointBase.
    # Other variables used in this script include:
    # SERVER_NAME - Name of the weblogic server.
    # JAVA_OPTIONS - Java command-line options for running the server. (These
    # will be tagged on to the end of the JAVA_VM and
    # MEM_ARGS)
    # For additional information, refer to the WebLogic Server Administration
    # Console Online Help(http://e-docs.bea.com/wls/docs92/ConsoleHelp/startstop.html).
    # Call setDomainEnv here.
    DOMAIN_HOME="/home/oracle/ocsgCourse/domains/labDomain"
    . ${DOMAIN_HOME}/bin/setDomainEnv.sh $*
    SAVE_JAVA_OPTIONS="${JAVA_OPTIONS}"
    SAVE_CLASSPATH="${CLASSPATH}"
    # Start PointBase
    PB_DEBUG_LEVEL="0"
    if [ "${POINTBASE_FLAG}" = "true" ] ; then
         ${WL_HOME}/common/bin/startPointBase.sh -port=${POINTBASE_PORT} -debug=${PB_DEBUG_LEVEL} -console=false -background=true -ini=${DOMAIN_HOME}/pointbase.ini >"${DOMAIN_HOME}/pointbase.log" 2>&1
    fi
    JAVA_OPTIONS="${SAVE_JAVA_OPTIONS}"
    SAVE_JAVA_OPTIONS=""
    CLASSPATH="${SAVE_CLASSPATH}"
    SAVE_CLASSPATH=""
    trap 'stopAll' 1 2 3 15
    if [ "${PRODUCTION_MODE}" = "true" ] ; then
         WLS_DISPLAY_MODE="Production"
    else
         WLS_DISPLAY_MODE="Development"
    fi
    if [ "${WLS_USER}" != "" ] ; then
         JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.management.username=${WLS_USER}"
    fi
    if [ "${WLS_PW}" != "" ] ; then
         JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.management.password=${WLS_PW}"
    fi
    CLASSPATH="${CLASSPATH}${CLASSPATHSEP}${MEDREC_WEBLOGIC_CLASSPATH}"
    echo "."
    echo "."
    echo "JAVA Memory arguments: ${MEM_ARGS}"
    echo "."
    echo "WLS Start Mode=${WLS_DISPLAY_MODE}"
    echo "."
    echo "CLASSPATH=${CLASSPATH}"
    echo "."
    echo "PATH=${PATH}"
    echo "."
    echo "***************************************************"
    echo "* To start WebLogic Server, use a username and *"
    echo "* password assigned to an admin-level user. For *"
    echo "* server administration, use the WebLogic Server *"
    echo "* console at http://hostname:port/console *"
    echo "***************************************************"
    # Set up IP Migration related variables.
    # Set interface name.
    if [ "${Interface}" != "" ] ; then
         IFNAME="${Interface}"
    else
         IFNAME=""
    fi
    # Set IP Mask.
    if [ "${NetMask}" != "" ] ; then
         IPMASK="${NetMask}"
    else
         IPMASK=""
    fi
    # Perform IP Migration if SERVER_IP is set by node manager.
    if [ "${SERVER_IP}" != "" ] ; then
         ${WL_HOME}/common/bin/wlsifconfig.sh -addif "${IFNAME}" "${SERVER_IP}" "${IPMASK}"
    fi
    # START WEBLOGIC
    echo "starting weblogic with Java version:"
    ${JAVA_HOME}/bin/java ${JAVA_VM} -version
    if [ "${WLS_REDIRECT_LOG}" = "" ] ; then
         echo "Starting WLS with line:"
         echo "${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} -Dweblogic.Name=${SERVER_NAME} -Djava.security.policy=${WL_HOME}/server/lib/weblogic.policy ${PROXY_SETTINGS} ${SERVER_CLASS}"
         ${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} -Dweblogic.Name=${SERVER_NAME} -Djava.security.policy=${WL_HOME}/server/lib/weblogic.policy ${PROXY_SETTINGS} ${SERVER_CLASS}
    else
         echo "Redirecting output from WLS window to ${WLS_REDIRECT_LOG}"
         ${JAVA_HOME}/bin/java ${JAVA_VM} ${MEM_ARGS} ${JAVA_OPTIONS} -Dweblogic.Name=${SERVER_NAME} -Djava.security.policy=${WL_HOME}/server/lib/weblogic.policy ${PROXY_SETTINGS} ${SERVER_CLASS} >"${WLS_REDIRECT_LOG}" 2>&1
    fi
    stopAll
    popd
    # Exit this script only if we have been told to exit.
    if [ "${doExitFlag}" = "true" ] ; then
         exit
    fi
    888stopManagedWeblogic.sh :
    #!/bin/sh
    # WARNING: This file is created by the Configuration Wizard.
    # Any changes to this script may be lost when adding extensions to this configuration.
    # --- Start Functions ---
    usage()
         echo "You must have a value for SERVER_NAME either set as an environment variable or the first parameter on the command-line."
         echo "ADMIN_URL defaults to t3://localhost:7001 if not set as an environment variable or the second command-line parameter."
         echo "USER_NAME and PASSWORD are required for shutting the server down when running in production mode:"
         echo "Usage: $1 {SERVER_NAME} {ADMIN_URL} {USER_NAME} {PASSWORD}"
         echo "for example:"
         echo "%1 managedserver1 t3://localhost:7001 weblogic weblogic"
    # --- End Functions ---
    # This script is used to stop a managed WebLogic Server for the domain in
    # the current working directory. This script reads in the SERVER_NAME and
    # ADMIN_URL as positional parameters, sets the SERVER_NAME variable, then
    # calls the startWLS.cmd script under ${WL_HOME}/server/bin.
    # Other variables that startWLS takes are:
    # WLS_USER - cleartext user for server startup
    # WLS_PW - cleartext password for server startup
    # JAVA_OPTIONS - Java command-line options for running the server. (These
    # will be tagged on to the end of the JAVA_VM)
    # JAVA_VM - The java arg specifying the VM to run. (i.e. -server,
    # -hotspot, etc.)
    # For additional information, refer to the WebLogic Server Administration
    # Guide (http://e-docs.bea.com/wls/docs92/adminguide)
    # Set SERVER_NAME and ADMIN_URL, they must by specified before starting
    # a managed server, detailed information can be found at
    # http://e-docs.bea.com/wls/docs92/adminguide
    if [ "$1" = "" ] ; then
         if [ "${SERVER_NAME}" = "" ] ; then
              usage %0
              exit
         fi
    else
         SERVER_NAME="$1"
         export SERVER_NAME
         shift
    fi
    if [ "$1" = "" ] ; then
         if [ "${ADMIN_URL}" = "" ] ; then
    ADMIN_URL="t3://localhost:8001"
              export ADMIN_URL
         fi
    else
         ADMIN_URL="$1"
         export ADMIN_URL
         shift
    fi
    DOMAIN_HOME="/home/oracle/ocsgCourse/domains/labDomain"
    ${DOMAIN_HOME}/bin/stopWebLogic.sh $1 $2
    999stopWebLogic.sh :
    #!/bin/sh
    # WARNING: This file is created by the Configuration Wizard.
    # Any changes to this script may be lost when adding extensions to this configuration.
    if [ "$1" != "" ] ; then
         userID="username='$1',"
         shift
    else
         if [ "${userID}" != "" ] ; then
              userID="username='${userID}',"
         fi
    fi
    if [ "$1" != "" ] ; then
         password="password='$1',"
         shift
    else
         if [ "${password}" != "" ] ; then
              password="password='${password}',"
         fi
    fi
    # set ADMIN_URL
    if [ "$1" != "" ] ; then
         ADMIN_URL="$1"
         shift
    else
         if [ "${ADMIN_URL}" = "" ] ; then
    ADMIN_URL="t3://localhost:8001"
         fi
    fi
    # Call setDomainEnv here because we want to have shifted out the environment vars above
    DOMAIN_HOME="/home/oracle/ocsgCourse/domains/labDomain"
    . ${DOMAIN_HOME}/bin/setDomainEnv.sh
    echo "connect(${userID} ${password} url='${ADMIN_URL}',adminServerName='${SERVER_NAME}')" >"shutdown.py"
    echo "shutdown('${SERVER_NAME}','Server')" >>"shutdown.py"
    echo "exit()" >>"shutdown.py"
    echo "Stopping Weblogic Server..."
    ${JAVA_HOME}/bin/java ${JAVA_OPTIONS} weblogic.WLST shutdown.py 2>&1
    echo "Done"
    exit

    This forum is about iAS. For weblogic go to: WebLogic Server - General

Maybe you are looking for

  • What to look for when i download

    Hi, Im a previous Dell user and as of today i converted to the macbook pro 13". Im still familiarizing myself with the laptop and the system. On my previous laptop i just downloaded things without a worry, however in the apple store today i was told

  • HP 6525 Paper Tray

    I had no problem setting up the Photosmart 6525 and it printed a test photo and worked fine for a month, but now when I keep getting a message telling me to reinsert or lower the paper tray. The photo tray is on top and the paper try on the bottom. I

  • How to send common msg

    Hi How to send common Msg to all the users presently logged in.This msg should appear as popup in a screen, tell me the procedure or tcode. regards gp

  • TS1424 I am unable to make In-App purchases through myiTunes Store account from my iPod touch.

    New iPod Touch 5. I purchased and successfully installed apps including iTranslate,Kitcam and Hotspot VPN. I am unable to make In-App purchases through my iTunes Store account. First error message "Your Purchase Could Not Be Completed, For assistance

  • Icloud mail not working

    Is anyone else having issues with iCloud mail only? I have not been able to access mail for over 12 hours.