Batch File Problem????????????

Dear All,
I have created a batch file which will Export the Logical Oracle dump everyday of the week in their respective days folder eg. SUN, MON, TUE etc..... are the folders
Now i am planning to put something like after taking Wednesdays backup the Mondays backup shuld be deleted automatically. I am confused how to set the Day-2 parameter in my bacth file. Below is my Batch file any suggestions wuld be of great help
BATCH FILE:
REM ########### Printing Date and Time ###########
set backup_bin=C:\Schedules\Backup
cd %backup_bin%
echo "#######################################" >>%backup_bin%\backup.log
echo "Backup process started" >>%backup_bin%\backup.log
date /t >>%backup_bin%\backup.log
time /t >>%backup_bin%\backup.log
REM ########### set backup_folder variables ###########
for /f "Tokens=1-4 Delims=/ " %%i in ('date /t') do set backup_day=%%i
set backup_folder=D:\Oracle_DB_Tape_Backups\%backup_day%
echo "backup folder is %backup_folder%" >>%backup_bin%\backup.log
REM ########### Oracle Dump into D:\Oracle_DB_Tape_Backups\*** folders ###########
echo "Oracle Dump process started" >>%backup_bin%\backup.log
date /t >>%backup_bin%\backup.log
time /t >>%backup_bin%\backup.log
exp userid=apregs_admin/apregs_admin file='%backup_folder%\fulldump.DMP' log='%backup_folder%\log.log'
date /t >>%backup_bin%\backup.log
time /t >>%backup_bin%\backup.log
echo "Oracle Dump process completed" >>%backup_bin%\backup.log
REM ########### DELETE FROM PREV FOLDERS D:\Oracle_DB_Tape_Backups\*** folders ###########
Regards

If you want to handle this automatically, then you'll have to encode the weekday and perform arithmetics with the SET os command.
I suggest you to use, rather, an S.O.S. (Script generated Out of SQL) You can handle the difficulties of dates directly in a sql script, then this script would generate the batch script, you would only schedule your sql script and it could generate the required os script.

Similar Messages

  • Runtime.exec() batch file problem

    Hi folks,
    i have a little problem when I want to execute a batch file through java's runtime.exec() method.
    the execution of a very simple batchfile works (for example opening notepad or other stuff), but I have problems with the following batch file (although it's still simple):
    net use s: \\Dd-nt-fs\Dsmp15_files
    set DSCFG=c:\dscfg
    set PSPATH=c:\adproof
    set ora_path=C:\oracle\ora92
    set path=S:\Dsmp_Q4_2004\Bin;%ora_path%\bin;%path%;
    set nd_font=S:\Dsmp_Q4_2004\Fonts
    set nxPS_FONT_DIR=%ND_FONT%
    set PSPATH=c:\adproof
    set PSFORMS=S:\Dsmp_Q4_2004\PsForms\Telenor
    s:
    cd S:\Dsmp_Q4_2004\bin
    S:\Dsmp_Q4_2004\Dsmp_Reports\Telenor\adproof.exe DBUSER=a_user DBPSWD=a_pswd DBSTR=dbstr ADINFO=adinfo.lst TASKID=a_taskid
    my guess is that there is a problem with the setting of environment variables which correspond to the drive s:
    I mannually added the batchfile (line by line) and looked whether it got through to the command which executes the adproof.exe file: for example the below batchfile worked:
    set DSCFG=c:\dscfg
    set PSPATH=c:\adproof
    set ora_path=C:\oracle\ora92
    s:
    cd S:\Dsmp_Q4_2004\bin
    S:\Dsmp_Q4_2004\Dsmp_Reports\Telenor\adproof.exe DBUSER=a_user DBPSWD=a_pswd DBSTR=dbstr ADINFO=adinfo.lst TASKID=a_taskid
    Here is the java code: in which i execute the batch file:
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec("net use s: \\\\Dd-nt-fs\\DSMP15_FILES");
    BufferedReader  b = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
    while( (line=b.readLine())!=null) {
          System.out.println(line);
    int exitVal = proc.waitFor();
    System.out.println("Exit Value = "  + exitVal);
    String[] cmd = new String[1];
    cmd[0] = "C:\\Documents and Settings\\tikmi\\My Documents\\mysources\\DSMP Prototype\\print\\hallo3.bat";
    // here i declared the needed settings of the environment variable and pass that array to the exec() method                   
    String[] env = new String[8];
    env[0] = "DSCFG=c:\\dscfg";
    env[1] = "ORA_PATH=C:\\oracle\\ora92";
    env[2] = "PSPATH=C:\\Documents and Settings\\tikmi\\My Documents\\mysources\\DSMP Prototype\\print";
    env[3] = "ND_FONT=S:\\Dsmp_Q4_2004\\Fonts";
    env[4] = "nxPS_FONT_DIR=%ND_FONT%";
    env[5] = "PSFORMS=S:\\Dsmp_Q4_2004\\PsForms\\Telenor";
    env[6] = "ND_PATH=S:\\Dsmp_Q4_2004\\resource";
    env[7] = "PATH=S:\\Dsmp_Q4_2004\\Bin;%ORA_PATH%\\BIN;%ND_PATH%;%PATH%;";
    rt  = Runtime.getRuntime();
    proc = rt.exec(cmd, env);
    b = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
    while( (line=b.readLine())!=null) {
              System.out.println(line);
    exitVal = proc.waitFor();
    System.out.println("Exit Value = "  + exitVal);Maybe someone else had similar problems or can help me solving that problem.
    Any advice would be very appreciated.
    regards
    mirkolino

    finally I got it working now.
    for those who are interested in the problem, my code that's now working is the following
    Runtime rt = Runtime.getRuntime();
                            Process proc = null;
                            String cmd = "cmd.exe /c c:\\adproof\\hallo3.bat";
                            proc = rt.exec(cmd);
                            InputStream in = proc.getInputStream();
                            BufferedReader br = new BufferedReader ( new InputStreamReader(in));
                            String line;
                            while( (line=br.readLine()) != null) {
                                System.out.println(line);
                            int exit = proc.waitFor();
                            System.out.println();
                            System.out.println("Process exited with: " + exit);the problem was, that i have to handle and read the input stream
    thanks for you help
    greetings from mirkolino

  • Running batch file error

    I have already tried to find some solution on Java Essential forum, not much success there. I hope someone might suggest something here.
    Design: one big file, split into chunks, recombined according to some order, feeded to some exe file, and finally compilation of results.
    Problem: I can run that smoothly with jdk, however, when I use Java beans I am running into troubles. I can split the file, create an order, recombine the files, but when I try to feed it to an exe file(through a batch file) i get this error:
    endfile record was detected in a READ statement (UNIT = 3). Error occurs at _MAIN__. A dubplicate file name exists or the file cannot be foundThe main method is something like this:
            s.split_ftn07() ;
            s.Define_Order() ;
            for (int i = 1 ; i < 11 ; i ++)
                s.re_combine(i) ;
                s.run_Fastran(i) ;
            s.ass_Result() ;my batch file:
    @echo off
    cd
    "C:\JBoss\jboss-4.0.5.GA\bin\Fastran\FASTRAN.EXE"
    ren FTN04 FTN04i
    :finishand my method that runs the batch file: (as soon as it pass the exec(), it opens the cmd.exe windows and displays the error message).
    public void run_Fastran(int x)
           try
               File ftn07_i = new File("C:\\JBoss\\jboss-4.0.5.GA\\bin\\Fastran\\ftn07_" + x) ;
               File ftn07 = new File("C:\\JBoss\\jboss-4.0.5.GA\\bin\\Fastran\\ftn07") ;
               ftn07_i.renameTo(ftn07) ;
               String path = "";
               path = "cmd /c start C:\\JBoss\\jboss-4.0.5.GA\\bin\\Fastran\\FCall.bat";
               Runtime rt = Runtime.getRuntime();
               Process proc = rt.exec(path);
               String nameNew = "C:\\JBoss\\jboss-4.0.5.GA\\bin\\Fastran\\FTN04-" + x + "-p12";//change p12 with the crack path input by user.
               File file = new File("C:\\JBoss\\jboss-4.0.5.GA\\bin\\Fastran\\FTN04i");
               while (file.exists()==false)//until FTNO4i come into existence
                // File with new name
               File file2 = new File(nameNew);
                // Rename file
               file.renameTo(file2);
               File ftn07Back = new File("C:\\JBoss\\jboss-4.0.5.GA\\bin\\Fastran\\ftn07") ;
               File ftn07_iBack = new File("C:\\JBoss\\jboss-4.0.5.GA\\bin\\Fastran\\ftn07_" + x) ;
               ftn07Back.renameTo(ftn07_iBack) ;
               File ftn07_i_del = new File("C:\\JBoss\\jboss-4.0.5.GA\\bin\\Fastran\\ftn07_" + x) ;
               ftn07_i_del.delete() ;
           catch(Exception e)
               e.printStackTrace();
        }I am tired to figure out whats going on? Need some help here, will be greatly appreciated. Thanks

    Thanks to all, I really appreciate all the pains which all of you have taken in resolving my problem.
    It wasn't Java problem, rather batch file problem. I was only changing the directory, and was not providing for the exe file to run.
    @echo off
    cd  "C:\JBoss\jboss-4.0.5.GA\bin\Fastran"
    "C:\JBoss\jboss-4.0.5.GA\bin\Fastran\FASTRAN.EXE"
    ren FTN04 FTN04i
    EXIT
    :finishNow it is working fine.
    I did check the access permissions, no problem with that I guess. The problem was with the path. The batch file couldnt go pass bin directory, and I noticed that only today ;(. At any rate, I changed that and now it is all smooth and dandy.
    Once again, thanks a lot.

  • Problems Force Running a batch file

    Hi There,
    I am trying to force-run a batch file to copy files from a local NBO Appliance to the C:\tmp directory on the user's workstation. The batch file lives at c:\tmp\branding.bat.
    I cant get the batch file to force run. Zen reporting advises that the batch file has distributed and launched successfully, however the files do not copy.
    However, if i click on the icon for the batch file app - the files copy no problem. I have tried running Workstation Associated and (Unrestricted) User Associated as well as Workstation - Force Run as User.
    Path to executable file:
    %*WinSysDir%\cmd.exe
    Parameters:
    /c "c:\tmp\branding.bat"
    Any ideas? The batch file has to refer to the P: drive as the application covers 40 different sites each with their own appliance containing source files.
    Running NBO2 - ZFD 4 Agent 4.0.1.60 - Clientless
    Desktop XP Workstations
    Thanks
    Thax

    Have the app object copy the batch file to the hard drive from the
    server and then run it locally. This should work with a Middle Tier server.
    thax wrote:
    > Hi there,
    >
    > I cant use the actual server name as this is an application which runs
    > through a middle tier server for multiple NBO sites so therefore needs to
    > use the P: reference...
    >
    >>>> kokoo<[email protected]> 9/03/2006 12:37 >>>
    >
    > TRY edit Scrirts:
    > #\\FS_SERVER_name\VOL\BATCH.BAT
    >
    > edit batch file:
    > xcopy "p:\nal\wxp\ZenPolicies\Branding\*.*" "C:\tmp\ZenPolicies\Branding\"
    > /s /v /e /y
    > ==>
    > xcopy p:\nal\wxp\ZenPolicies\Branding\*.* C:\tmp\ZenPolicies\Branding\ /s
    > /v /e /y
    >
    > "thax" <[email protected]>
    > *******:[email protected]...
    > Hi Jeremy,
    >
    > xcopy "p:\nal\wxp\ZenPolicies\Branding\*.*" "C:\tmp\ZenPolicies\Branding\"
    > /s /v /e /y
    > pause
    >
    > Thax
    >
    > >>> Jeremy Mlazovsky<[email protected]> 8/12/2005 00:20
    >
    > Can we see the contents of your batch file?
    >
    > thax wrote:
    > > Hi There,
    > >
    > > I am trying to force-run a batch file to copy files from a local NBO
    > > Appliance to the C:\tmp directory on the user's workstation. The batch
    >
    > > file lives at c:\tmp\branding.bat.
    > >
    > > I cant get the batch file to force run. Zen reporting advises that the
    >
    > > batch file has distributed and launched successfully, however the files
    >
    > > do not copy.
    > >
    > > However, if i click on the icon for the batch file app - the files copy
    >
    > > no problem. I have tried running Workstation Associated and
    > > (Unrestricted) User Associated as well as Workstation - Force Run as
    > User.
    > >
    > >
    > > Path to executable file:
    > >
    > > %*WinSysDir%\cmd.exe
    > >
    > > Parameters:
    > >
    > > /c "c:\tmp\branding.bat"
    > >
    > > Any ideas? The batch file has to refer to the P: drive as the
    > > application covers 40 different sites each with their own appliance
    > > containing source files.
    > >
    > > Running NBO2 - ZFD 4 Agent 4.0.1.60 - Clientless
    > >
    > > Desktop XP Workstations
    > >
    > > Thanks
    > >
    > > Thax
    > >
    >
    >
    Jeremy Mlazovsky
    Senior System Engineer - Enterprise Desktop
    UDit-Central Hardware Systems & Network Storage
    University of Dayton
    http://forge.novell.com/modules/xfmod/project/?udimage
    http://vmpconfig.sourceforge.net/
    http://regeditpe.sourceforge.net

  • Problem with running rhcl.exe in batch file

    Hi,
    I'm running Robohelp 8 and trying to use rhcl.exe to generate multiple help projects. I'm having a problem with the folder where the rhcl.exe is generating the web help. It seems to ignore the "-o" switch and gets the generation folder from the project all the time. As you can see from the log file below, the exe appears to pick up the "-o" path  (......\Test\Opportunities.htm), but writes the generated files to the path in the project (.....\Opportunities\index.htm).
    Anyone else come across this problem?
    MY BATCH FILE IS:
    "C:\Program Files\Adobe\Adobe RoboHelp 8\RoboHTML\rhcl.exe" "C:\Data\RoboHelp\RoboHelp Projects\SubProjects\SupplierPortal\Opportunities\Opportunities.xpj" -l Webhelp -o "C:\Data\RoboHelp\GeneratedWebHelp\SupplierPortal\mergedProjects\Test" -g "C:\Data\RoboHelp\GeneratedWebHelp\Generate.log"
    THE LOG FILE CREATED IS:
    Adobe (R) RoboHelp Project Command Line Compiler version 8.0.0.203
    Copyright (C) 2006-2007, Adobe Systems Incorporated and its licensors. All rights reserved.
    Project: C:\Data\RoboHelp\RoboHelp Projects\SubProjects\SupplierPortal\Opportunities\Opportunities.xpj
    Layout: WebHelp.
    Output: C:\Data\RoboHelp\GeneratedWebHelp\SupplierPortal\mergedProjects\Test\Opportunities.htm.
    Scanning project for compilation....
    Scanning finished.
    Warning: No baggage file description.
    Starting compilation...
    WebHelp preprocessor 8.0.0.203
    Compiling C:\Data\RoboHelp\GeneratedWebHelp\SupplierPortal\mergedProjects\Opportunities\index.htm ...
    Preparing to create WebHelp...
    Clearing output folder...
    Preparing files for WebHelp...
    Copying files...
    Updating files...
    Finished preparing in 1 sec(s)
    Initializing compiler...
    Generating WebHelp 5.50 (8.0.0.203)...
    Processing TOC data...
    Processing Context-sensitive-Help data...
    Updating HTML topics...
    Updating opportunities/e-auctions/how_do_i/creating_a_new_bid.htm...
    Updating opportunities/e-auctions/how_do_i/creating_a_response.htm...
    Updating opportunities/e-auctions/how_do_i/viewing_auction_details.htm...
    Updating opportunities/e-auctions/how_do_i/viewing_bid_details.htm...
    Updating opportunities/e-auctions/how_do_i/viewing_a_list_of_auctions.htm...
    Updating opportunities/e-auctions/how_do_i/withdrawing_from_an_auction.htm...
    Updating opportunities/e-auctions/screen_level_help/list_of_auctions.htm...
    Updating opportunities/e-auctions/screen_level_help/new_bid.htm...
    Updating opportunities/e-auctions/screen_level_help/view_auction_details.htm...
    Updating opportunities/e-auctions/screen_level_help/view_bid_details.htm...
    Updating opportunities/e-auctions/introduction_to_e-auctions.htm...
    Updating opportunities/introduction_to_opportunities.htm...
    Finished updating HTML topics in 0 sec(s) : total 12 topic(s).
    Processing Full-text-search data...
    Finished processing Full-Text-Search data in 0 sec(s)
    Applying WebHelp 5.50 Template...
    Finished applying Template in 1 sec(s)
    Processing Mark of the Web...
    Finished compiling WebHelp in 3 sec(s)
    Compilation complete.

    Hi again
    And that's why we call them bugs.
    Did you remember to report it as same to Adobe? The link is in my sig.
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML within the day - $24.95!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • Problem Executing Batch File

    I wrote out a java class that I tried using cfobject to call. It didn't work. So I wrote a batch file to call the java class.  The batch file works, but NOt when I have coldfusion call it. Nothing happens, no error... nothing.  I thought it might be a permissions issue, but I tried changing permissions for coldfusion although I may have doneit wrong since I'm not too familiar with Vista.  Can anyone offer advice on what I can do.  Its a simple java class and I can't get it to run.  no errors in the log.  There isn't much for me to go on.  All I know is that the class and batch file work fine if Coldfusion doesn't call them.

    Amosl wrote:
    To limit the problems with the class itself and cfobject, I've created a batch file to run the class.  The batch file runs the class fine, so long as I execute the batch via command line.  But coldfusion doesn't execute the batch with cfexecute.  the same exact problem with absolutely no error messages.
    Unfortunately, cfexecute is not the easiest tag to debug. In my experience sometimes it confuses more than clarifies.  But trying it is not a bad idea from a troubleshooting point of view.
    However,  if I create a java class in the same folder that doesn't write to the system and only returns variables, it works fine.  This indicates the class path is set correctly and that cfobject does work.
    Yes, I would agree.
    It does sound like it might be a permissions issue. But I have little experience with Vista, so there may well be another cause.  Since it sounds like you are just testing a very simple java class, can you post the code for the class itself as well as the exact cfexecute code you are using? I could test it on another operating system. Just to see if there is some obvious problem.
    Amosl wrote:
    From the 100's of pages I've read online with people with similar problems, this seems to be a permissions issue.  however, I've set Coldfusion to run as me, the administrator and only person who uses this computer.  It is no longer running as local system.
    However, this didn't fix anything.  My only guess is that perhaps I've no set it to run as me correctly.  But I have no way of testing this.  Windows logs show no error messages either.  Is there any way to have coldfusion show me what user its trying to execute the batch as.
    I believe the user account can be obtained from the java system properties.  Try:
    <cfset sys = createObject("java", "java.lang.System")>
    <cfoutput>
       <b>user.name</b> = #sys.getProperty("user.name", "not found")#<hr>
       <b>coldfusion.classPath</b> = #sys.getProperty("coldfusion.classPath")#<br>
    </cfoutput>

  • Problem wiht Running Batch File using Runtime.exec()

    I am writting one program which will create a jar file using a windows Batch file.
    The main program is in the folder "d:\CmdExec.java".
    The other one to which a jar file to be created is in the folder "e:\folder\HelloWorld.class"
    The contents inside the "e:\folder" are
    e:\folder\HelloWorld.class
    e:\folder\mainClass.txt
    e:\folder\run.bat
    The mainClass.txt contains "Main-Class: HelloWorld"
    The Run.bat file contains "jar cmf mainClass.txt HelloWorld.jar *.class"
    The coding for CmdExec.java is as follows
    import java.io.*;
    import java.awt.Desktop;
    public class CmdExec {
    public static void main(String argv[]) {
    try {
    Desktop desktop = null;
    if (Desktop.isDesktopSupported()) {
    desktop = Desktop.getDesktop();
    desktop.open(new File("e:\\folder\\run.bat"));
    catch (Exception err) {
    err.printStackTrace();
    When i double click the file e:\folder\Run.bat, it will create a jar file for HelloWorld.class.
    But, i want to create that jar file using the java program CmdExec.java.
    When i run CmdExec.java, the batch file is opened. But it shows error as "Can't find the specified file"
    But when i copy the following files to "d:\",
    e:\folder\HelloWorld.class
    e:\folder\mainClass.txt
    the jar file is created using the CmdExec.java.
    But,
    e:\folder\HelloWorld.class
    e:\folder\mainClass.txt
    these files should be in the folder"e:\folder" only.
    Can anyone Help me this Problem?
    Or Anyother way for creating a jar file for one program by using another program?
    Help me soon.............

    Try this. It's not running a bat file. You can say it almost is a bat file.
    import java.io.*;
    import java.util.Scanner;
    public class CmdExec {
        public static void main(String argv[]) {
            try {
                Process p = Runtime.getRuntime().exec("jar cmf mainClass.txt HelloWorld.jar *.class");
                Scanner s1=new Scanner(new InputStreamReader(p.getInputStream()));
                while(s1.hasNextLine())
                    System.out.println(s1.nextLine());
                p.waitFor();
                System.out.println(p.exitValue());
                if(p.exitValue()==0)
                    System.out.println("Okay");
                else
                    System.out.println("Error");
            catch (Exception ex) {
                ex.printStackTrace();
    }Run it in the same folder as mainClass.txt
    Edited by: ColacX on Aug 1, 2008 10:35 AM

  • Problem on using batch file

    Hi,
    I have an application which reads data from a text and writes them to a database. I should use batch files in my project to work classes with double clicking on them. Java application reads path of the text file from a properties file. I used relative paths like that " ..\\data\\records.txt" for text file path . But my problem is that; when I run application normally it executes. But when I tried to run it from batch file placed build folder(under project folder) it does not work. Because it tries to find the data folder under the build folder. But data folder is under parent folder of build folder. My batch file code is like that :
    SET PATH=%JAVA_HOME%\bin;%PATH%
    SET LIB_PATH=..\lib
    SET CLASSPATH=%LIB_PATH%\mysql-connector-java-3.0.17-ga-bin.jar;..\bin;..\
    java.exe yega.timesheet.MainApplication ..\\configuration\\properties.props
    pause
    Which statements should I add(and where) to make this batch file search for data folder under its parent folder... Please help me.
    Thank you.

    Thanks Paul, but I tried to use cd before running program. I added "cd .." or "cd ..\" lines to batch file but they didn't work. I decided to use absolute path instead of using relative paths. I also found one more solution. I can put a properties file in build too. And define text path as " ..\\data\\records.txt " in this properties file.
    Also I need to use "\\" because "..\\configuration\\properties.props" is the input for args...

  • Problem using Host command to call a batch file

    Hi all,
    I am trying to call a batch file with the Host command:
    host c:\test\u.bat
    where u.bat calls unix2dos.exe with a parameter of d_unix.txt.
    Bat file looks like this:
    C:\test\unix2dos.exe d_unix.txt
    PAUSE
    The bat file gets called fine, but the following error occurs (in the cmd prompt):
    T:\globals\ORACLE8\bin>C:\test\unix2dos.exe d_unix.txt
    d_unix.txt:
    Can't open file
    T:\globals\ORACLE8\bin>PAUSE
    Press any key to continue . . .
    Running the batch file directly in windows works fine. The batch file also runs fine from the Host command if I remove the d_unix.txt parameter.
    The file d_unix.txt file is in the same directory as the batch file and as unix2dos.exe.
    Running from Sql Plus in a windows environment.
    Any thoughts?
    Edited by: dgouin on Aug 19, 2009 11:41 AM
    Edited by: dgouin on Aug 19, 2009 11:42 AM
    Edited by: dgouin on Aug 19, 2009 11:42 AM

    I always understood that it worked with whatever directory you were in when you launched the SQL*Plus binary:
    D:\>SQLPLUS dbuser@testdb
    SQL*Plus: Release 10.2.0.4.0 - Production on Wed Aug 19 15:26:35 2009
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Enter password:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    dbuser@testdb > HOST ECHO %CD%
    D:\
    dbuser@testdb > exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    D:\>H:
    H:\>SQLPLUS dbuser@testdb
    SQL*Plus: Release 10.2.0.4.0 - Production on Wed Aug 19 15:27:03 2009
    Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
    Enter password:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    dbuser@testdb > HOST ECHO %CD%
    H:\
    dbuser@testdb > exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options

  • Problem in connecting to sqlplus from windows batch file (DOS)

    Hi All,
    We have a new 10g Oracle database installed on windows server. I am trying to write a windows batch file to
    1) Connect to SQLPLUS
    2) Execute a script
    3) Disconnect from SQLPLUS.
    Example File Name:- execsql.bat
    SET ORACLE_SID=CAUT
    SET SCHEMA_IN=%1
    SET PASS=DEV
    SET script=%2
    sqlplus %SCHEMA_IN%/%PASS%@%ORACLE_SID% @%script%
    if %errorlevel% NEQ 0 echo ERROR: %ERRORLEVEL% else echo OK
    Now if i run this bat file like :- execsql.bat DEV script1.sql
    DEV= schema name,
    script1.sql = this file contains select * from dual;
    The code runs fine, but if i change dual to dual1 the sql error's out but not able to catch the error in the batch file.
    Reason why i would like to catch the error is this batch file would be scheduled through Autosys job scheduler and for autosys any exit code >0 is an error. Please help me in rewriting this batch script.
    Thanks
    Sam.

    Hello,
    What if you run this in SQL*Plus before you run the SELECT:
    whenever sqlerror exit failure

  • [Solved] Problem getting Batch Files to run as Admin in Win 8.1

    I'm trying to control certain Services with batch files to have them stop automatically at start.  However, with certain services, stopping requires run as admin.  My user account has admin privileges.
    For example, a batch file with this command will stop with a command prompt requiring Y/N to confirm the stop.
    NET STOP "Audiosrv"
    I can create a shortcut and set it to run as admin and it will stop the service without issue when it's clicked.  However, if I put the shortcut in the Windows startup folder, so the script runs automatically at boot it seems to ignore the shortcuts.
    I've tried the RunAs command below in a batch file, but it doesn't stop the service.
    runas /user:jaguar\Admin NET STOP "Audiosrv"
    Thanks for your help.

    Hello Peter, that works great.   I found I can add multiple arguments by separating them with a semi colon and I could hide the powershell window with the command at the end.
    My last question is if there's an additional command that will hide or minimize the command line window when the script runs?
    powershell.exe "Start-Process powershell -ArgumentList 'stop-service audiosrv; stop-service AudioEndpointBuilder; stop-service MMCSS' -Verb RunAs" -windowstyle hidden

  • Problem with a simple batch file

    Hello
    in my test lab, I am creating a cmd batch file which first sets the system execution policy to bypass & then continues into command prompt & does some stuff there. so I need the following commands be run in turn:
    powershell set-executionpolicy bypass -force
    cmd
    @echo off
    echo the installation of the following App will take about 10 minutes
    cd c:\myfolder
    myApp.exe
    but only the first line of the command runs & it ends up in the following step:
    any help please !

    You cannot jsut run a list of commands.  You also cannot use PowerShell to execute BAT commands.  Start by learning how to create and run a classic BAT file or jsut skip BAT files and run PowerShell.
    powershell -command "Write-Host ' the installation of the following App will take about 10 minutes' -fore green; cd c:\myfolder;myApp.exe"
    Just past that at a prompt or place the whole line in a barch file.
    OR - skip Powershell altogether and run a batch file only.
    This would be you batch file:
    @echo off
    echo the installation of the following App will take about 10 minutes
    cd c:\myfolder
    myApp.exe
    ¯\_(ツ)_/¯

  • Problem while executing batch file via jsp

    Scenario 1+
    I have a batch file(.bat) in which i have the following code
    mkdir d:\test\test1;
    mkdir d:\test\test2;
    mkdir d:\test\test3;
    mkdir d:\test\test4;
    mkdir d:\test\test5;
    mkdir d:\test\test6;
    mkdir d:\test\test7;
    mkdir d:\test\test8;
    mkdir d:\test\test9;
    mkdir d:\test\test10;when i double click on this or execute via cmd all the 10 directories are created successfully.
    Scenario 2+
    But when i try to execute this through a jsp using the following code,Only first 5 directories are created.Please help me in resolving the issue ASAP.Thanks in advance
    <%@page import="javax.swing.*"%>
    <%@page import="javax.swing.JFileChooser"%>
    <%@page import="java.awt.event.*"%>
    <%@page import="java.awt.*"%>
    <%@ page import="java.io.*"%>
    <%@ page import="java.util.*"%>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
        <title>untitled2</title>
      </head>
      <body><%
            Runtime.getRuntime().exec("d:\\test.bat");
                    System.out.println("Inside Try Block");
                  %>
        hi</body>
    </html>I am using Jdeveloper.

    carrera wrote:
    Then can u suggest any other way how i can invoke a batch file from html/jsp.I think what some of the previous posters wanted to make clear is that jsps are not the place to go calling batch files. Jsp's are normally the view part and don't actually trigger these type of actions directly. Call a servlet to do non-view things...
    If all you want to do is execute an ant file, look for examples for running ant through java api. f.i. here

  • Guide to External Jobs on 10g with dbms_scheduler e.g. scripts,batch files

    GUIDE TO RUNNING EXTERNAL JOBS ON 10g WITH DBMS_SCHEDULER
    NOTE: Users using 11g should use the new method of specifying a credential which eliminates many of the issues mentioned in this note.
    This guide covers several common questions and problems encountered when using
    dbms_scheduler to run external jobs, either on Windows or on UNIX.
    What operating system (OS) user does the job run as ?
    External jobs which have a credential (available in 11g) run as the user
    specified in the credential. But for jobs without credentials including
    all jobs in 10gR1 and 10gR2 there are several cases.
    - On UNIX systems, in releases including and after 10.2.0.2 there is a file $ORACLE_HOME/rdbms/admin/externaljob.ora . All external jobs not in the SYS schema and with no credential run as the user and group specified in this file. This should be nobody:nobody by default.
    - On UNIX systems, in releases prior to 10.2.0.2 there was no "externaljob.ora" file. In this case all external jobs not in the SYS schema and with no credential run as the owner and group of the $ORACLE_HOME/bin/extjob file which should be setuid and setgid. By default extjob is owned by nobody:nobody except for oracle-xe where it is owned by oracle:oraclegroup and is not setuid/setgid.
    - On Windows, external jobs not in the SYS schema and with no credential run as the user that the OracleJobScheduler Windows service runs as. This service must be started before these jobs can run.
    - In all releases on both Windows and UNIX systems, external jobs in the SYS schema without a credential run as the oracle user.
    What errors are reported in SCHEDULERJOB_RUN_DETAILS views ?
    If a job fails, the first place to look for diagnostic information is the SCHEDULERJOB_RUN_DETAILS set of views. In 10gR2 and up the first 200 characters of the standard error stream is included in the additional_info column.
    In all releases, the error number returned by the job is converted into a
    system error message (e.g. errno.h on UNIX or net helpmsg on Windows) and that
    system error message is recorded in the additional info column. If there is no
    corresponding message the number is displayed.
    In 11g and up the error number returned by the job is additionally recorded in
    the error# column. In earlier releases 27369 would always be recorded in the
    error# column.
    Generic Issues Applicable to UNIX and Windows
    - The job action (script or executable) must return 0 or the job run will be marked as failed.
    - Always use the full pathname to executables and scripts.
    - Do not count on environment variables being set in your job. Make sure that the script or executable that your jobs runs sets all required environment variables including ORACLE_HOME, ORACLE_SID, PATH etc.
    - It is not recommended to pass in a complete command line including arguments as the action. Instead it is recommended to pass in only the path to and name of the executable and to pass in arguments as job argument values.
    - Scripts with special characters in the execution path or script name may give problems.
    - Ensure that the OS user your job runs as has the required privileges/permissions to run your job. See above for how to tell who the job runs as.
    - External job actions cannot contain redirection operators e.g. > < >> | && ||
    - In general try getting a simple external job working first e.g. /bin/echo or ipconfig.exe on Windows. Also try running the job action directly from the commandline as the OS user that the job will run as.
    Windows-specific Issues
    - The OracleJobScheduler Windows service must be started before external jobs will run (except for jobs in the SYS schema and jobs with credentials).
    - The user that the OracleJobScheduler Windows service runs as must have the "Log on as batch job" Windows privilege.
    - A batch file (ending in .bat) cannot be called directly by the Scheduler. Instead cmd.exe must be used and the name of the batch file passed in as an argument. For example
    begin
    dbms_scheduler.create_job('myjob',
       job_action=>'C:\WINDOWS\SYSTEM32\CMD.EXE',
       number_of_arguments=>3,
       job_type=>'executable', enabled=>false);
    dbms_scheduler.set_job_argument_value('myjob',1,'/q');
    dbms_scheduler.set_job_argument_value('myjob',2,'/c');
    dbms_scheduler.set_job_argument_value('myjob',3,'c:\temp\test.bat');
    dbms_scheduler.enable('myjob');
    end;
    /- In 10gR1 external jobs that wrote to standard output or standard error streams would sometimes return errors. Redirect to files or suppress all output and error messages when using 10gR1 to run external jobs.
    UNIX-specific Issues
    - When running scripts, make sure that the executable bit is set.
    - When running scripts directly, make sure that the first line of the script in a valid shebang line - starting with "#!" and containing the interpreter for the script.
    - In release 10.2.0.1, jobs creating a large amount of standard error text may hang when running (this was fixed in the first 10.2.0.2 patchset). If you are seeing this issue, redirect standard error to a file in your job. This issue has been seen when running the expdp utility which may produce large amounts of standard error text.
    - the user that the job runs as (see above section) must have execute access on $ORACLE_HOME/bin and all parent directories. If this is not the case the job may be reported as failed or hang in a running state. For example if your $ORACLE_HOME is /opt/oracle/db then you would have to make sure that
    chmod a+rx /opt
    chmod a+rx /opt/oracle
    chmod a+rx /opt/oracle/db
    chmod a+rx /opt/oracle/db/bin
    - On oracle-xe, the primary group of your oracle user (if it exists) must be dba before you install oracle-xe for external jobs to work. If you have an oracle user from a regular Oracle installation it may have the primary group set to oinstall.
    - On oracle-xe, the extjobo executable is missing so external jobs in the SYS schema will not work properly. This can be fixed by copying the extjob executable to extjobo in the same directory ($ORACLE_HOME/bin).
    - Check that correct permissions are set for external job files - extjob and externaljob.ora (see below)
    Correct permissions for extjob and externaljob.ora on UNIX
    There is some confusion as to what correct permissions are for external job related files.
    In 10gR1 and 10.2.0.1 :
    - rdbms/admin/externaljob.ora should not exist
    - bin/extjob should be setuid and setgid 6550 (r-sr-s---). It should be owned by the user that jobs should run as and by the group that jobs should run as.
    - bin/extjobo should have normal 755 (rwxr-xr-x) permissions and be owned by oracle:oraclegroup
    In 10.2.0.2 and higher
    - rdbms/admin/externaljob.ora file must must be owned by root:oraclegroup and be writable only by the owner i.e. 644 (rw-r--r--) It must contain at least two lines: one specifying the run-user and one specifying the run-group.
    - bin/extjob file must be also owned by root:oraclegroup but must be setuid i.e. 4750 (-rwsr-x---)
    - bin/extjobo should have normal 755 (rwxr-xr-x) permissions and be owned by oracle:oraclegroup
    In 11g and higher
    Same as 10.2.0.2 but additionally bin/jssu should exist with root setuid
    permissions i.e. owned by root:oraclegroup with 4750 (-rwsr-x---)
    Internal Error numbers for UNIX on 10.2.0.2 or 10.1.0.6 or higher
    If you are not using a credential and are using version 10.2.0.2 or higher or 10.1.0.6 or higher you may come across an internal error number. Here are the meanings for the internal error numbers.
    274661 - can't get owner of or permissions of externaljob.ora file
    274662 - not running as root or externaljob.ora file is writable by group or other or externaljob.ora file not owned by root (can't switch user)
    274663 - setting the group or effective group failed
    274664 - setting the user or effective user failed
    274665 - a user or group id was not changed successfully
    274666 - cannot access or open externaljob.ora file
    274667 - invalid run_user specified in externaljob.ora file
    274668 - invalid run_group specified in externaljob.ora file
    274669 - error parsing externaljob.ora file
    274670 - extjobo is running as root user or group

    Hi Ravi,
    Can you help me...
    Hi All,
    I planned to create a job to do rman backup daily at 04:00 AM.
    1. I created a program as follows
    BEGIN
    DBMS_SCHEDULER.CREATE_PROGRAM(
    program_name => 'rman_backup_prg',
    program_action => '/u02/rmanback/rman.sh',
    program_type => 'EXECUTABLE',
    comments => 'RMAN BACKUP');
    END;
    my rman script is
    #!/usr/bin/ksh
    export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
    export PATH=$PATH:/u01/app/oracle/product/10.2.0/db_1/bin
    /u01/app/oracle/product/10.2.0/db_1/bin/exp rman/cat@catdb file=/u02/rmanback/rm
    an_220108.dmp log=/u02/rmanback/rman_220108.log owner=rman statistics=none comp
    ress=n buffer=400000
    compress *.dmp
    exit
    2. I created a schedule as follows
    BEGIN
    DBMS_SCHEDULER.CREATE_SCHEDULE(
    schedule_name => 'rman_backup_schedule',
    start_date => SYSTIMESTAMP,
    end_date => '31-DEC-16 05.00.00 AM',
    repeat_interval => 'FREQ=DAILY; BYHOUR=4',
    comments => 'Every day at 4 am');
    END;
    3. I created ajob as follows.
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'rman_backup_job',
    program_name => 'rman_backup_prg',
    schedule_name => 'rman_backup_schedule',
    enabled=> true,
    auto_drop=> false
    END;
    While I am running the job I am getting the following error anybody help me.
    ORA-27369: job of type EXECUTABLE failed with exit code: Not owner
    ORA-06512: at "SYS.DBMS_ISCHED", line 150
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 441
    ORA-06512: at line 2
    If I removed "compress *.dmp" line in rman script it is working fine.
    /* additional Info from dba_scheduler_job_run_details as follows */
    ORA-27369: job of type EXECUTABLE failed with exit code: Not owner
    STANDARD_ERROR="
    Export: Release 10.2.0.3.0 - Production on Tue Jan 22 14:30:08 2008
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to: Oracle Database 10g Release 10.2.0.3.0 - Production
    Export"
    Regards,
    Kiran

  • Executing batch file from Java stored procedure hang

    Dears,
    I'm using the following code to execute batch file from Java Stored procedure, which is working fine from Java IDE JDeveloper 10.1.3.4.
    public static String runFile(String drive)
    String result = "";
    String content = "echo off\n" + "vol " + drive + ": | find /i \"Serial Number is\"";
    try {
    File directory = new File(drive + ":");
    File file = File.createTempFile("bb1", ".bat", directory);
    file.deleteOnExit();
    FileWriter fw = new java.io.FileWriter(file);
    fw.write(content);
    fw.close();
    // The next line is the command causing the problem
    Process p = Runtime.getRuntime().exec("cmd.exe /c " + file.getPath());
    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
    while ((line = input.readLine()) != null)
    result += line;
    input.close();
    file.delete();
    result = result.substring( result.lastIndexOf( ' ' )).trim();
    } catch (Exception e) {
    e.printStackTrace();
    result = e.getClass().getName() + " : " + e.getMessage();
    return result;
    The above code is used in getting the volume of a drive on windows, something like "80EC-C230"
    I gave the SYSTEM schema the required privilege to execute the code.
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'java.io.FilePermission', '&lt;&lt;ALL FILES&gt;&gt;', 'read ,write, execute, delete');
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    GRANT JAVAUSERPRIV TO SYSTEM;
    I have used the following to load the class in Oracle 9ir2 DB:
    loadjava -u [system/******@orcl|mailto:system/******@orcl] -v -resolve C:\Server\src\net\dev\Util.java
    CREATE FUNCTION A1(drive IN VARCHAR2) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'net.dev.Util.a1(java.lang.String) return java.lang.String';
    variable serial1 varchar2(1000);
    call A1( 'C' ) into :serial1;
    The problem that it hangs when I execute the call to the function (I have indicated the line causing the problem in a comment in the code).
    I have seen similar problems on other forums, but no solution posted
    [http://oracle.ittoolbox.com/groups/technical-functional/oracle-jdeveloper-l/run-an-exe-file-using-oracle-database-trigger-1567662]
    I have posted this in JDeveloper forum ([t-853821]) but suggested to post for forum in DB.
    Can anyne help?

    Dear Peter,
    You are totally right, I got this as mistake copy paste. I'm just having a Java utility for running external files outside Oracle DB, this is the method runFile()
    I'm passing it the content of script and names of file to be created on the fly and executed then deleted, sorry for the mistake in creating caller function.
    The main point, how I claim that the line in code where creating external process is the problem. I have tried the code with commenting this line and it was working ok, I made this to make sure of the permission required that I need to give to the schema passing security permission problems.
    The function script is running perfect if I'm executing vbs script outside Oracle using something like "cscript //NoLogo aaa1.vbs", but when I use the command line the call just never returns to me "cmd.exe /c bb1.bat".
    where content of bb1.bat as follows:
    echo off
    vol C: | find /i "Serial Number is"
    The above batch file just get the serial number of hard drive assigned when windows formatted HD.
    Same code runs outside Oracle just fine, but inside Oracle doesn't return if I exectued the following:
    variable serial1 varchar2(1000);
    call A1( 'C' ) into :serial1;
    Never returns
    Thanks for tracing teh issue to that details ;) hope you coul help.

Maybe you are looking for

  • Authorization at Company Code Level for table FEBKO

    Hello Experts, I need to add authorization check on my report program that accesses and displays data from table FEBKO. However the user should only be able to access the data of table FEBKO particular only for their company code. How can I apply thi

  • My iphone 4's backlight turns off ocassionally.,some say update it and it will be ok..,anybody can help me?

    my iphone 4's backlight turns off ocassionally.,some say update it and it will be ok..,anybody can help me?

  • Join, and filter...

    When doing a join, and filtering, I want the filter to be applied first. For example if the callDisp file for the given date has 18 rows, and the treeProject has 47 records SELECT COUNT(*) from treeProject, callDisp Where treeProject.projectcode = ca

  • Lightroom 3.2 Tethered shooting with Nikon D7100

    I have a laptop Windows Vista which will not allow me to upgrade Lightroom 3.2 to 5.3. I have bought a Nikon D7100. Is it possible to enable the older version of LIghtroom 3.2 to recognise the Nikon D7100 for tethered shooting? Cheers.

  • LSMW in background mode not working properly

    Hi, I am doing LSMW in background mode. But I am facing problem in SM35. The session is ended with sessions. Wt I am trying to do here is: I have 4 fields on the screen in which 4 th field is non-editable field. I am concatenating first 3 fields and