Jump to content

hem852

Member
  • Posts

    13
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United Kingdom

Everything posted by hem852

  1. Hi I found that if instead of doing this COPY /V E:\CognosData\Cubes\%filename%\old\*.mdc E:\CognosData\Cubes\%filename%\temp.mdc I do this RENAME E:\CognosData\Cubes\%filename%\old\*.mdc temp.mdc copy /V E:\CognosData\Cubes\%filename%\old\temp.mdc E:\CognosData\Cubes\%filename%\temp.mdc Then everything works fine. In the script everything from SET JAVA_HOME to -namespaceid="0001" including the %CLASSPATH% stuff is code provided by IBM Cognos and is used heavily by most Cognos 8 server implementations so I am assuming it would not be a problem. Thanks for all your help. Regards John
  2. Hi, With a fair amount of help I have written the following batch file to move some files about, do some renaming and stuff like that. (I'm fairly new to this stuff so please forgive if this is badly written) @ECHO OFF REM ---- Fetch parameters from command line ---- SET dts=%1 SET file1=%2 REM ---- Configure UNC path ---- net use \\llsvr-bur-3334\d$ /user:LLEE\ca.autosys auto5y5 REM ---- Split the cube filename into useable portions ---- CALL :PARSEVAR %file1% :EOF REM ---- Create cube working directories if they do not exist ---- IF NOT EXIST E:\CognosData\Cubes\%filename% md E:\CognosData\Cubes\%filename% IF NOT EXIST E:\CognosData\Cubes\%filename%\old md E:\CognosData\Cubes\%filename%\old REM ---- Rename any existing mdc in old dir to .bak and copy exisitng mdc to old directory ---- RENAME E:\CognosData\Cubes\%filename%\old\*.mdc *.bak copy E:\CognosData\Cubes\%filename%\*.mdc E:\CognosData\Cubes\%filename%\old\ del E:\CognosData\Cubes\%filename%\*.mdc REM ---- Compact files in old directory to save disk space ---- e: cd E:\CognosData\Cubes\%filename%\old\ compact.exe /C REM ---- Copy mdc file from build server ---- COPY /V %file1% %newfile% IF ERRORLEVEL 1 GOTO :ERROR del E:\CognosData\Cubes\%filename%\old\*.bak REM ---- Navigate to Cubeswap Directory & call Cognos Java App --- d: cd\"program files"\cognos\c8\webapps\utilities\cubeSwap SET JAVA_HOME=../../../bin/jre/1.4.2/ SET CRN_HOME=../../../ SET JAR_HOME=%CRN_HOME%webapps/p2pd/WEB-INF/lib SET CLASSPATH=. SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/axis.jar SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/axisCrnpClient.jar SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/commons-discovery.jar SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/commons-logging.jar SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/jaxrpc.jar SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/saaj.jar SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/xml-apis.jar SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/xercesImpl.jar "%JAVA_HOME%bin/java.exe" -classpath %CLASSPATH% CubeSwap -dispatchername="http://llsvr-bur-3333:9300" -datasource=%dts% -url="http://llsvr-bur-3333:9300/p2pd/servlet/dispatch" -windowscube="%newfile%" -username="user" -password="pass" -namespaceid="0001" GOTO :END :ERROR COPY /V E:\CognosData\Cubes\%filename%\old\*.mdc E:\CognosData\Cubes\%filename%\temp.mdc d: cd\"program files"\cognos\c8\webapps\utilities\cubeSwap SET JAVA_HOME=../../../bin/jre/1.4.2/ SET CRN_HOME=../../../ SET JAR_HOME=%CRN_HOME%webapps/p2pd/WEB-INF/lib SET CLASSPATH=. SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/axis.jar SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/axisCrnpClient.jar SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/commons-discovery.jar SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/commons-logging.jar SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/jaxrpc.jar SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/saaj.jar SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/xml-apis.jar SET CLASSPATH=%CLASSPATH%;%JAR_HOME%/xercesImpl.jar "%JAVA_HOME%bin/java.exe" -classpath %CLASSPATH% CubeSwap -dispatchername="http://llsvr-bur-3333:9300" -datasource=%dts% -url="http://llsvr-bur-3333:9300/p2pd/servlet/dispatch" -windowscube="E:\CognosData\Cubes\%filename%\temp.mdc" -username="user" -password="pass" -namespaceid="0001" ECHO. ECHO Cubeswap Failed ECHO. GOTO :END :PARSEVAR SET fullname=%~1 SET fullpath=%~f1 SET drive=%~d1 SET filename=%~n1 SET fileext=%~x1 SET firstpart=%~dpn1 SET FileTime=%Time::=-% SET FileTime=%FileTime:.=-% SET addedpart=%DATE:/=-%_%FileTime% SET addedpart=%addedpart: =% SET newfile="E:\CognosData\Cubes\%filename%\%filename%_%addedpart%%fileext%" :GOTO EOF :END The batch file seems to work perfectly until the :ERROR part of the script is needed. For some reason that I cannot quite work out, the copy command only copies about 21k of the file. Does anyone have any idea what might be causing this? Everything else is working fine, even the rest of the :ERROR section. Thanks in advance for any help. Regards John FYI : This is being run on Windows 2003 Server standard edition.
  3. The final batch file is shown below. It works like a dream in our scheduler so thanks to all for your help in getting this working. The only remaining issue I have to resolve is that this overwrites the exisiting file if run more than once per day for the same file. Ideally I need to be keeping all of the last weeks files. I tried to include the time element in the newfile variable but could not get this working because %time% contains characters that are not legal in file names. Is there a way of splitting the time elements or changing the delimiter it uses? @ECHO OFF REM #### Fetch parameters from command line #### SET DTS=%1 SET file1=%2 REM #### Configure UNC path #### net use \\server\d$ /user:DOMAIN\username password REM #### Split the cube filename into useable portions #### CALL :PARSEVAR %file1% FOR %%A IN ( file1 fullname fullpath drive filename fileext firstpart addedpart newfile) DO SET %%A :EOF REM #### Check if cube directory exists and create if it does not #### IF NOT EXIST E:\CognosData\Cubes\%filename% md E:\CognosData\Cubes\%filename% REM #### Copy cube file from build server to app server #### COPY %file1% %newfile% REM #### Now run the cubeswap code #### set JAVA_HOME=../../../bin/jre/1.4.2/ set CRN_HOME=../../../ set JAR_HOME=%CRN_HOME%webapps/p2pd/WEB-INF/lib set CLASSPATH=. set CLASSPATH=%CLASSPATH%;%JAR_HOME%/axis.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/axisCrnpClient.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/commons-discovery.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/commons-logging.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/jaxrpc.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/saaj.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/xml-apis.jar set CLASSPATH=%CLASSPATH%;%JAR_HOME%/xercesImpl.jar "%JAVA_HOME%bin/java.exe" -classpath %CLASSPATH% CubeSwap -dispatchername="http://llsvr-bur-3315:9300" -datasource=%DTS% -url="http://server/p2pd/servlet/dispatch" -windowscube="%newfile%" -username="user" -password="pass" -namespaceid="0001" :PARSEVAR SET fullname=%~1 SET fullpath=%~f1 SET drive=%~d1 SET filename=%~n1 SET fileext=%~x1 SET firstpart=%~dpn1 SET addedpart=%DATE:/=-% SET newfile="E:\CognosData\Cubes\%filename%\%filename%_%addedpart%%fileext%" :GOTO EOF Thanks again for all your help. Very much appreciated. John
  4. Jaclaz, I now have it working perfectly, just needed a little tweaking and I was able to do this with the help of the http://www.robvanderwoude.com/ site you pointed me towards. Thank you very much. Regards John
  5. Thanks to everyone for their help, especially Jaclaz, I now have a working script but..... Is there a way to make the script wait for a file copy to complete before continuing? Some of the files I am using this to copy are rather big and cant take 10 minutes or so to copy. Is there a way to get just the just the files parent directory into a variable? For example if a file is in directory c:\dir1\dir2\dir3\file is it possible to set a variable to just contain whatever dir3 may be? Thanks again to everyone for your help. It really is greatly appreciated. Regards John
  6. Thank you for this very valuable info Jaclaz, very much appreciated, I'm sure I can work with this. John
  7. No unfortuantely not, the application that uses the created files insists that they appear in one location only, it can only point to one directory. John
  8. To clarify, they are used by the cubeswap.bat script called at the end of the script. I think there is only one not defined and that was a simple typo where I am having to copy from one screen to another because the machine we are trying to do this on has no access to the web. The variables NAME and FILENAME should be the same thing. Sorry about that. What I want ideally is the date after the filename but before is the only way I could get this to work. I was hoping someone could explain how I swap these around without messing up the file extension. If the date has to go before then putting year first would make finding a file difficult as over the course of a month we are going to end up with 2400+ files in this directory at any one time. I figured it is easier to find a file amongst 80 with the same day number at the beginning than to try and attempt to find a file amongst 2400+ files all starting with the same year. Put simply what I want to do is take file A from server A and copy it to server B renaming the copy on server B to be the original filename plus the date of copy. So a file named 'file.txt' on sever A would become 'file_dd-mm-yyyy_hh-mm.txt' on server B. I then need to pass the fully qualified filename on server B to another script called Cubeswap.bat I appreciate I have probably made a bit of a mess of this in the first place but as I mentioned its the first time I have ever tried to write a windows batch file and I'd rather 'have a go' before I asked for help. The idea being, when we get this working is we can use the batch file in a scheduler to automate these copies each night. Thanks for all the help so far, I'm still working on this so would still welcome more suggestions. Regards John
  9. Well I liked ME, got so much work fixing it or uninstalling it and replacing with 98SE. Made a fortune because of its failings so how could I hate it?
  10. Is there anything in the event log on the problem machines? Has this always been a problem on them or has their been a recent update that may have caused the problem? I have seen a similar thing before where a windows update caused problems. From memory we got around the problem temporarily by disabling the screen saver. Try disabling it on one machine and see if the problem is still apparent. If its not it gives us something to work on. Regards John
  11. Hi I am trying to write a batch file that will copy a file from one network drive to another and rename it on the new location so the filename has the date at the end. Below is what I have so far but this is not working. It hits problems with files that have spaces in them, sometimes returns the error 'NET is not a valid command' and does not wait until the file is finished copying before moving on to the next command. I can also only get the date added to the begining of the file when ideally I need it at the end. @@echo off REM Fetch the file name from the command line SET FILENAME=%2 SET DTS=%1 net use \\llsvr-bur-3330\d$ /USER:DOMAIN\username password net use \\llsvr-bur-3333\e$ /USER:DOMAIN\username password REM Create the date and time elements. For /f "tokens=1-7 delims=:/-, " %%i in ('echo exit^|cmd /q /k"prompt $D $T"') do ( For /f "tokens=2-4 delims=/-,() skip=1" %%a in ('echo.^|date') do ( set dd=%%i set mm=%%j set yy=%%k set hh=%%l set min=%%m set ss=%%n ) ) REM COPY FILE AND RENAME WITH DATE AND TIME APPENDED SET NEW_FILE=%dd%-%mm%-%yy%_%hh%%min%_%NAME% START /WAIT /B COPY /V %NAME% %NEW_FILE% CALL CUBESWAP.bat Could someone possibly give me some help sorting this out please? Sorry if this seems like a bit of a hopeless attempt, its my first attempt at windows batch files! Thanks in advance for any help. John
×
×
  • Create New...