Starting SQLPlus via batch script

Hi,
When I type in: sqlplus USER/PASS@SERVER at command prompt it starts SQL Plus in the command prompt.
Now when I save this command as .bat file and then execute this bat file it doesn't start SQL Plus. It just keeps on executing this command continuously.
How can I start SQL Plus via a batch file.
Thanks in advance,
Raja

> Once I execute the bat script it just keeps on executing this command endlessly on the command
prompt.
This is typically how you should start SQL*Plus in "batch" mode. Note, the script does not use the command line for the username and password, as that will make it visible to others via a process listing (that typically includes the command line for that process).
/home/billy> cat x.sh
#!/bin/sh
sqlplus -s /nolog <<EOF
set heading off
set feedback off
connect scott/tiger
select sysdate from dual;
exit;
EOF
/home/billy> ./x.sh
2008-06-11 07:33

Similar Messages

  • Error starting db via batch script: Cannot communicate with crsd

    Hi,
    I've installed Oracle 11g on a Windows 7 64 bit laptop, and I have no problems starting the database using Windows Services
    I tried starting the db using the batch command, but received the following error:
    C:\Users\Scott>C:\app\Scott\oracle\11.2.0\11gr2_home\BIN\srvctl.bat start database -d sw11g
    PRCD-1027 : Failed to retrieve database sw11g
    PRCR-1070 : Failed to check if resource ora.sw11g.db is registered
    Cannot communicate with crsd
    Have I missed a parameter?
    Cheers

    No, this is my laptop where I'm using the DB as an experimental tool etc.
    This was my attempt in placing a shortcut on my desktop for startup.

  • Stopping/starting BO4 via scheduled script (SIA enough?)

    Hi,
    We are wishing to implement a backup stratgey for our new BO4 deployment running on 2 windows servers against Oracle 11 CMS database.
    Wish to have cold backups in addition to hot ones.
    In order to implement cold backups will need to bring the BOE services down via script.
    Just wondered as to best practice.
    1) Is it sufficient to simply stop the SIA via script and what would command be.  In old XIR2 we have net stop and net start server names.
    I'm assuiming fine to leave Tomcat up and running during this time - will be for up to 1 hr during night when nobody using system.
    Many Thanks
    Edited by: Philip O'Rourke on Jan 14, 2012 12:58 PM

    Create a file C:\Windows\reboot-script.bat and put the following command string in it:
    shutdown /r /f /d P:4:1
    /r  = reboot
    /f  = force running applications to close (this shuts down BOE and Tomcat)
    /d  P:4:1  = the reason for the reboot (P=Planned)
         the numbers are Major and Minor reasons for the reboot
         4:1 = Application:Maintenance
         4:2 = Application:Installation
    (The /d and it's following parameters are not really necessary but I put them in there so that my Wintel support team can see the reboot is planned and executed by me)
    With that one command string in your *.bat file, you can then use Task Scheduler to "Start a Program" at the specified time you need.
    CAUTION:  If you set this up and run it under your own ID, that can lead to inconsistent results.  It's really much better to run it as SYSTEM (your Windows Admin has to get involved) or a Service Account.  This is on the General tab of the Task Scheduler.

  • Windows 8.1 Batch Scripts for devcon.exe

    HiI'm using batch script with devcon.exe for cleaning usb ghost devices. On XP and Win 7 it works perfect but on windows 8.1 only if i manualy paste commands on "administrator command line" but it wont start from my batch script. Is there any solution for windows 8 to enable security rule for batch script? Win 8 is so annoying for any type of scripts even gpo. At the moment im trying to resolve this problem with PowerShell.This is how script looks like:
    Text@echo offDEVCON Find * | FIND /I /V "matching device(s)" > "%Temp%\DevconFind.txt"FOR /F "tokens=1 delims=: " %%A IN ('DEVCON FindAll * ^| FIND /I /V "matching device(s)"') DO (TYPE "%Temp%\DevconFind.txt" | FIND "%%~A" >NULIF ERRORLEVEL 1 %Debug% DEVCON Remove "@%%~A")DEL "%Temp%\DevconFind.txt"
    Regards
    This topic first appeared in the Spiceworks Community

    Uninstall it.  Reboot.  Then install.  Reboot.
    All of this should be done as Run as Administrator or it will fail.
    16GIG or Larger usb flash drive is required.  8 gigs is too small.
    http://www.dell.com/support/home/us/en/19/Drivers/DriversDetails?driverId=8HY96

  • Batch script auto start in administrator mode

    Hello
    i use in Windows 7 after start batch script with administrator mode. Work fine.
    in Windows 8.1 this batch do not start after login Windows. Where is error? I find similar error or do not exists help...
    This is not working for me in Windows 8.  I have a shortcut to an EXE file located in"C:\Users\admin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup".  If I set the shortcut to run as administrator (screenshot attached)
    then it does not run at all on startup.  If I uncheckmark "Run as Administrator" then it starts fine (but does not have enough privileges to do what it needs to do).  In Windows 7 this was not an issue since the current user was a local
    administrator and did not need to elevate its privileges further.
    Any ideas how I can work around this problem?  Thanks!
    Ugh... it won't let me attach a screenshot until my "account is verified", whatever that means.

    Consider scheduling your command to run via the Task Scheduler.  Trigger it to run at login.  I think you'll find you'll have no problems running a program with full Administrative privileges that way.
    -Noel
    Detailed how-to in my eBooks:  
    Configure The Windows 7 "To Work" Options
    Configure The Windows 8 "To Work" Options

  • Is it possible to start a batch script from Sharepoint?

    Hi,
    I want to start a batch script from Sharepoint which executes some sql queries.
    Can someone guide me how to start a batch (.bat) script in SP?

    Yes and no.  If your script is scheduled to run by some other process (which it should be, because it very likely has  to be run as some account and not the web app account), you should set the script to look for a setting in a sharepoint list,
    if that setting tells the script to run, then it does.  This means that, yes, you can start a batch script from sharepoint.
    To be able to execute a script directly from sharepoint...no.
    Chris Givens CEO, Architecting Connected Systems
    Blog Twitter

  • Starting applications from a keynote via Apple Script?

    Is there any way to start an application from a keynote via Apple Script?

    Welcome to the forums!
    Keynote does not support the use of AppleScript in that fashion.

  • Start and shutdown Oracle10g (WinXP) via Batch?

    Hi,
    I installed Oracle10g at my Notebook (WinXP) and I don't need it every day. So I'd like to shutdown all oracle Services and start all services like a Batch-Script or Icon at my Desktop.
    Is there any way to start an shutdown all Oracle jobs?
    Thanks
    Winni

    To add,
    And of course you will NEVER use "net stop blabla" on a prod DB.
    Never.
    You can also use:
    emctl stop (to stop the enterprise manager)
    agentctl stop (to stop the dbsnmp - think the cmd did not change in 10g, but can't check atm)
    oradim -shutdown -sid DBNAME -shuttype srvc,inst -shutmode i (to stop the instance and service. execute "oradim" to have all options)
    lsnrctl stop (stops the listener)Other services still running? you can now net stop them.
    Regards,
    Yoann.

  • Change currently active LV version in batch script

    Hello,
    I use two different applications on my computer and one of them should run in LV 2011, the other one in LV 2012. Both versions are installed and it works fine as long as I start the correct LV version manually before starting the application (by starting and closing the required LV version from C:\Program Files (x86)\National Instruments\... before starting my application).
    I want to do this automatically in a command script, so basically I want to do the following:
    * Check which LV version is currently active (which LV version was started last)
    * If the currently active LV version is NOT the required one: change to the required LV version (by starting LV and closing it, or preferably doing it differently if someone could tell me how)
    * If the currently active LV version is the required one: Do nothing
    There are two problems I could not solve so far:
    * How do I get the currently active LV version (I checked windows registry, but I only see my installed LV versions, and not which one is currently active)
    * How can I close LV with a batch script (or how can I change the currently active LV version w/o opening and closing it)
    Thanks in advance,
      Tobias
    PS: I did the same for different TestStand versions, by reading out the TestStand system environment variable and if requuired changing the TestStand version via the command line of the TS Version Selector. This works fine, but there is no system environement variable that tells the currently active LV version.
    Solved!
    Go to Solution.

    They might have different toolkits installed. Block diagrams on our old projects are included, but on our new projects we plan to not include them anymore. Driver compatibilty is a problem that we check each time we have this situation with different versions to make sure that it is working as expected. On one project I did not install the new driver, but kept the old one to make sure there are no changes to the old project.
    It is a problem when we execute old code with a newer LV version than the version was used during the validation of the same code. We probably would have to do some revalidation with the newer LV version and this is what I try to avoid (working in the medical device industry means a lot of validation).
    I could not find the current LV version in the Windows registry. But it must be located somewhere, since TestStand gives the Active LV Version in the LV Adapter configuration and when I open a VI in Windows Explorer the last used LV version is started.
    So my question is where does TestStand and Win Explorer read this out, since then I could read the same thing out in my batch script.

  • How to call a batch script from DI?

    Hi All,
    I'm new to DI/DS and would like to know is there a way to call a batch sciprt (.bat file) in DI?
    What I try to do is,
    1.call a batch script to move source files from a file server to the source folder before kicking off the data flow
    2. once the data flow is completed, call a batch script to move the processed source files to the achive folder.
    In other ETL tool like informatica it can be done via the command task, is there something similar in DI?
    Any help would be appreciated.
    Regards
    BL

    Thanks Suneer.
    Just want to clarify, when I create the script task in the work flow, should I put the path of my batch file or the batch script itself in?
    e.g., my batch script is movefile.bat under folder C:\Script,
    and the command is:  move /Y "C:\Input\*.*". "C:\Archive\".
    in the script task, should I put
    exec('cmd', 'C:\Script\movefile.bat')
    or
    exec('cmd', 'move /Y "C:\Input\*.*". "C:\Archive\".')
    Thanks again for your help
    Regards,
    BL

  • Calling oracle procedure from batch script

    i have a .bat file, in which i am using sqlldr to load into a staging table from csv file, and then using merge to insert / update into target table
    i have 2 doubts
    1) my first doubt is regarding batch script..how to handle the errorlevels which are greater than 1?
    so generally speaking, how do i handle all the errors at once..and make sure the control goes to
    run_sqlldr0 always? and handle the error meaningfully if its other than 0 ?
    below is my batch script, and i get error
    goto run_sqlldr2
    the system cannot find the batch label specified - run_sqlldr2
    @echo on
    call oraenv.bat
    if not exist %mainpath% goto mainpath_def
    if not exist %scripts% goto scriptspath_def
    if not exist %logs% goto logspath_def
    if not exist %data% goto datapath_def
    goto x1
    :x1
    goto run_sqlldr%ERRORLEVEL%
    echo run_sqlldr%ERRORLEVEL%
    if run_sqlldr%ERRORLEVEL% NEQ 0 goto run_sqlldr1
    echo "entering sqlldr"
    :run_sqlldr1
    echo "entered sqlldr1"
    echo "some error"
    echo mergedata%ERRORLEVEL%
    :run_sqlldr0
    echo "entered sqlldr0"
    sqlldr userid = scott/tiger@orcl control=%mainpath%\cm.ctl log=%logs%\cm.log discard=%logs%\cm.dsc bad=%logs%\cm.bad SILENT=(HEADER, FEEDBACK)
    goto mergedata%ERRORLEVEL%
    :mergedata1
    echo "entered mergedata1"
    echo cleandata%ERRORLEVEL%
    :mergedata0
    sqlplus -s scott/tiger@orcl @%scripts%\merge_stg.sql
    goto cleandata%ERRORLEVEL%
    :cleandata1
    echo "entered cleandata1"
    sqlplus -s scott/tiger@orcl @%scripts%\clean_stg.sql
    goto exit
    :cleandata0
    echo "entered cleandata0"
    echo "error in removing data"
    goto exit
    :mainpath_def
    echo "mainpath not existing as specified %mainpath%, Please edit ORAENV with correct value"
    goto exit
    :scriptspath_def
    echo "scripts path not existing as specified %scripts%, Please edit ORAENV with correct value"
    goto exit
    :logspath_def
    echo "Logs path not existing as specified %logs%, Please edit ORAENV with correct value"
    goto exit
    :datapath_def
    echo "Data path not existing as specified %data%, Please edit ORAENV with correct value"
    goto exit
    :exit
    2) my second doubt, is this the right way of calling the stored procedures merge_stg and clean_stg?
    in clean_stg, i use dynamic sql to truncate the staging table
    create or replace procedure trunstg is
    lsql varchar2(2000) := 'truncate table stg_ldrtest';
    begin
    execute immediate lsql;
    end;
    /

    i have changed the code
    @echo on
    call oraenv.bat
    if not exist %mainpath% goto mainpath_def
    if not exist %scripts% goto scriptspath_def
    if not exist %logs% goto logspath_def
    if not exist %data% goto datapath_def
    goto x1
    :x1
    goto run_sqlldr%ERRORLEVEL%
    echo run_sqlldr errorlevel: %ERRORLEVEL%
    if run_sqlldr%ERRORLEVEL% NEQ 0 goto run_sqlldr1
    echo "entering sqlldr"
    :run_sqlldr1
    echo "entered sqlldr1"
    echo "some error"
    :run_sqlldr2
    echo errorlevel: %errorlevel%
    echo mergedata%ERRORLEVEL%
    :run_sqlldr0
    echo "entered sqlldr0"
    sqlldr userid = gautam/gautam@orcl control=%mainpath%\cm.ctl log=%logs%\cm.log discard=%logs%\cm.dsc bad=%logs%\cm.bad SILENT=(HEADER, FEEDBACK)
    goto mergedata%ERRORLEVEL%
    :mergedata1
    echo "entered mergedata1"
    goto end
    echo cleandata%ERRORLEVEL%
    :mergedata0
    sqlplus -s gautam/gautam@orcl @%scripts%\merge_stg.sql
    goto cleandata%ERRORLEVEL%
    :cleandata1
    echo "entered cleandata1"
    echo "cleaning error"
    goto end
    :cleandata0
    sqlplus -s gautam/gautam@orcl @%scripts%\clean_stg.sql
    goto end
    :mainpath_def
    echo "mainpath not existing as specified %mainpath%, Please edit ORAENV with correct value"
    goto exit
    :scriptspath_def
    echo "scripts path not existing as specified %scripts%, Please edit ORAENV with correct value"
    goto exit
    :logspath_def
    echo "Logs path not existing as specified %logs%, Please edit ORAENV with correct value"
    goto exit
    :datapath_def
    echo "Data path not existing as specified %data%, Please edit ORAENV with correct value"
    goto exit
    :end
    EXIT
    so the error is ORA - 30926, unable to get a stable set of
    rows in the source tables
    my merge is
    MERGE INTO ldrtest D
    USING (SELECT code,id,row_name,col1,col2,col3,crt_tm,md_tm,crt_user,mod_usr FROM stg_ldrtest) S
    ON (d.code = s.code and d.id = s.id and d.row_name=s.row_name )
    WHEN MATCHED THEN UPDATE SET d.col1 = s.col1,
    d.col2 = s.col2,
    d.col3 = s.col3,
    d.crt_tm = s.crt_tm,
    d.md_tm = s.md_tm,
    d.crt_user = s.crt_user,
    d.mod_usr = s.mod_usr
    WHEN NOT MATCHED THEN INSERT (d.code,d.id,d.row_name,d.col1,d.col2,d.col3,d.crt_tm,d.md_tm,d.crt_user,d.mod_usr)
    VALUES (s.code,s.id,S.row_name, s.col1,s.col2,s.col3,s.crt_tm,s.md_tm,s.crt_user,s.mod_usr);
    i did not understand what this error means..
    could anyone please help me out

  • Using MaxL in batch script to get Essbase database size before proceeding

    I have a batch script which dynamically generates some MaxL before passing it to ESSMSH. I would like to insert a command at the beginning of the MaxL script, to get and assess the size of the database before proceeding. If the database is empty I would like the script to quit. This is to prevent the script from exporting data and overwriting the previous export file if the database is empty.
    The generated MaxL (modified) is currently as follows. What logic can I add to the MaxL script, to assess the database size and go to the "errorhandler" label if it is empty? Is this even possible?
    login %USER% identified by %PASS% on %SERVER%;
    iferror "errorhandler";
    /* log file */
    spool stdout on to '<directory>.log';
    iferror "errorhandler";
    /* error file */
    spool stderr on to '<directory>.err';
    iferror "errorhandler";
    /* export data */
    set timestamp on;
    execute calculation %APP%.%DB%.C_Export;
    iferror "errorhandler";
    /* reset database */
    alter database %APP%.%DB% reset data;
    iferror "errorhandler";
    /* import data */
    import database %APP%.%DB% data from server data_file "<filename>.txt" on error abort;
    iferror "errorhandler";
    /* calculate database */
    execute calculation default on %APP%.%DB%;
    iferror "errorhandler";
    /* error handler */
    spool off;
    define label "errorhandler";
    logout;
    exit;

    Hi Stuart,
    Yes I was aware of display database "app"."db"; however this will output a table rather than a specific value. And what logic can I then add to the MaxL script to assess the specific value of "Db Status" and go to the "errorhandler" label if it is empty?
    It would seem this needs to be done via a VBScript, to loop through the file rows to find the value before proceeding accordingly. But I was hoping there might be a way to do this within MaxL.

  • Sql*loader in batch script

    Hi,
    I am calling a sqlloader and a procedure within a loop inside a batch script.
    Sometimes, The sqlloader fails and subsequent procedure fails, I am not able move to the next iteration.
    How to catch oracle errors in batch script
    Thx.

    hi,
    My batch script is something like this.
    I want to catch errors when
    1. sql*loader throws error
    2. when my pl/sql throws error.
    I welcome any suggestions to improve this code.
    d:
    echo cd Data\Scripts
    for %%f in (D:\Data\DELIVERY_NOTE\*.csv) Do (
    echo conn config/config;
    echo delete from SQLLOAD_DELIVERY_STAGE;
    )| sqlplus -s /nolog
    sqlldr USERID=config/config control=D:\Data\Scripts\loaddata_del.ctl skip=2 data=%%f
    echo conn config/config;
    echo exec DELIVERY_NOTE_PKG.Populate_Del_Note_stage;
    echo exec DELIVERY_NOTE_PKG.PROCESS_DELIVERY_NOTE;
    )| sqlplus -s /nolog
    move %%f D:\Data\Processed_Delivery\
    cd D:\Data\processed_Delivery\
    rename *.csv *.csv.processed
    cd d:\Data\scripts\
    echo #############
    echo PROCESSED THE FILE %%f AT %data% %time%
    echo ############
    )

  • Stopping/Starting Portal via BAT file on Windows

    In our landscape we have the ABAP and JAVA stack installed on separate servers for security reason.  We are trying to implement windows updates via SUS and need to automate the stopping and starting of SAP.  The bat file that was created works when stopping and starting the ABAP portion of SAP but on the Portal server it will take it down but when trying to start Portal, the J2ee Server will not start, but when I use the SAP MMC all servers starts up without any problem.  Below is the start up bat file, any assistance will be greatly appreciated:
    REM start of script
    PATH=%path%;G:\usr\sap\QBE\SYS\exe\uc\NTAMD64
    SET ORACLE_SID=QBE
    SET SAPDATA_HOME=K:\ORACLE\QBE
    REM
    REM
    REM ***** starting Oracle Services *****
    REM
    net start OracleQBE102TNSListener
    net start OracleServiceQBE
    net start OracleQBE102iSQL*Plus
    REM
    REM ***** starting SAP services *****
    REM
    net start SAPOsCol
    net start SAPQBE_00
    net start SAPQBE_01
    REM
    REM ***** starting SAP Instances ******
    REM
    G:\usr\sap\QBE\SYS\exe\uc\NTAMD64\startsap.exe name=QBE nr=00 SAPDIAGHOST=SAPEPQA
    G:\usr\sap\QBE\SYS\exe\uc\NTAMD64\startsap.exe name=QBE nr=01 SAPDIAGHOST=SAPEPQA
    REM
    REM end of script

    I looked up some training material and in TADM10 - Unit4 - Starting and Stopping a SAP NetWeaver AS Java.. the following is stated:
    Under Windows, the SAP system can also be started and stopped without a GUI by
    calling a command by means of the executable files startsap.exe and stopsap.exe. This
    can be done using a simple telnet access.
    To start an instance of the SAP system, open a telnet connection and enter the
    following command: startsap name=<SID> nr=<instance nr.>
    SAPDIAHOST=<hostname>
    To stop an instance of the SAP system, open a telnet connection and enter the
    following command: stopsap name=<SID> nr=<instance nr.>
    SAPDIAHOST=<hostname>
    For the SAPDIAHOST parameter, enter the name of the host on which the instance is
    to be started.
    So the script is correct, its all according to SAP advice... very strange

  • How can I enable java applet plug-in and Web Start applications via terminal?

    Since the last Java update to Snow Leopard, I have found that the system periodically disables the Java applet plug-in after a period of disuse.  I know I can go to /Applications/Utilities/Java Preferences and just click to re-enable Java.  But I want to write a script which will do this periodically for a couple hundred Mac users where I work. 
    My question is - how can I reenable the Java applet plug-in and web start applications via Terminal command?  Is this possible?  Is there a plist file that can be modified, etc.?
    Bob Reed

    It is my understanding that Apple's most recent Java update automatically disables Java after a certain period of time that it hasn't been used.  We don't want users to have to keep re-enabling it.  So we wanted to find a way to do this via script either run by a Casper JSS server or stored locally on each workstation.   With the guidance provided by Mark Jalbert above and some text from a script written by Rich Trouton, I was able to make a script (with some minor changes) and a launch agent to re-run the script upon login.  So the preference is always enabled.
    For your reference, the script content is:
    #!/bin/sh
    # DYNAMICALLY SET THE UUID FOR THE BYHOST FILE NAMING
    if [[ `ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-50` == "00000000-0000-1000-8000-" ]]; then
    MAC_UUID=`ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c51-62 | awk {'print tolower()'}`
    elif [[ `ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-50` != "00000000-0000-1000-8000-" ]]; then
    MAC_UUID=`ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-62`
    fi
    # Set the the "Enable applet plug-in and Web Start Applications" setting in the Java Preferences for the current user.
    /usr/libexec/PlistBuddy -c "Delete :GeneralByTask:Any:WebComponentsEnabled" /Users/$USER/Library/Preferences/ByHost/com.apple.java.JavaPreferences.${MAC_UU ID}.plist
    /usr/libexec/PlistBuddy -c "Add :GeneralByTask:Any:WebComponentsEnabled bool true" /Users/$USER/Library/Preferences/ByHost/com.apple.java.JavaPreferences.${MAC_UU ID}.plist
    /usr/libexec/PlistBuddy -c "Delete :GeneralByTask:Any:WebComponentsLastUsed" /Users/$USER/Library/Preferences/ByHost/com.apple.java.JavaPreferences.${MAC_UU ID}.plist
    /usr/libexec/PlistBuddy -c "Add :GeneralByTask:Any:WebComponentsLastUsed real $(( $(date "+%s") - 978307200 ))" /Users/$USER/Library/Preferences/ByHost/com.apple.java.JavaPreferences.${MAC_UU ID}.plist
    The launch agent plist content is:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
              <key>Disabled</key>
              <false/>
              <key>Label</key>
              <string>org.XXXXX.enableJavaPlugin</string>
              <key>ProgramArguments</key>
              <array>
                        <string>sh</string>
                        <string>/Library/Scripts/XXXXX/enableJava_plugin.sh</string>
              </array>
              <key>RunAtLoad</key>
              <true/>
              <key>StartOnMount</key>
              <true/>
    </dict>
    </plist>
    I hope this is helpful to anyone wishing to keep the Java web plugin enabled.
    Bob
    Message was edited by: Robert Reed2

Maybe you are looking for