I am using Cognos Event studio to schedule reports to write output CSV files at file location. Apparently, the output file has suffix "en-gb". is it possible to rename the files using cognos.
for the moment i have created a Batch script to rename the files. Is there a way to run the batch script using cognos event studio?
I cannot use it using stored procedure as DBAs will not let me to export it to cognos.
Thanks
Gary
research on CM.OUTPUTSCRIPT
not sure though if this feature is still in v11
CM.OUTPUTSCRIPT is in the documentation for CA11. What I don't know is what Cognos wants for a path. Does it want something like e:\foldername\script.bat, or file://\\servername\sharename\script.bat? Are there examples available. What I have found online in the last couple hours has been useless.
its been a while since i've done this... your server is windows right? why don't you experiment first with a simple batch file?
for example copy x.txt y.txt
then try the each path see which one works?
i could experiment as well from my end but it will take time. i recon you will can get the answer before i can get back to you
Uhmm... Yeah...
I already have a script and I have set the value of the property. The script isn't being called. It's not a permissions problem. As I stated, I don't see any examples of what, exactly, to enter for the value of the CM.OUTPUTSCRIPT variable.
just curious... have you set the "save the report to file system" property to "yes"?
Yes. Reports get saved to the location I expect. The script just doesn't get called.
If the account running the scheduled report has its language preference set to en-gb, then shouldn't the prefix on the filename be removed?
ok took me a while to find time to restart the server services and experiment on this.
i encountered the issue wherein files gets saved but batch file seems it did not run. batch file looks like this:
copy x.txt y.txt
then i changed it to explicit directory definition
copy c:\temp\x.txt c:\temp\y.txt
it worked.
Did it not run, or did it not work?
What happens if you change the file like this to make it start in the correct directory and perform logging?
@echo OFF
@rem --------------------------------------------------------------
@rem
@rem --------------------------------------------------------------
setlocal
@rem store the drive and path of this file in a variable
set dirname=%~dp0
@rem cd to the directory containing this file
pushd %dirname%
@rem do stuff
echo log entry 1 >> log.txt
copy x.txt y.txt
@rem cd back to where we started
popd
endlocal
it did run for me.
why don't you try running a simple batch file first like i did?
You said it didn't run.
Quotei encountered the issue wherein files gets saved but batch file seems it did not run. batch file looks like this:
copy x.txt y.txt
Now you are saying it did run? Which is it?
Quote from: Francis aka khayman on 11 Feb 2020 08:29:39 AM
then i changed it to explicit directory definition
copy c:\temp\x.txt c:\temp\y.txt
it worked.
So when the bat file was
copy x.txt y.txt
did it not run or did it not work?
i would say it worked in the sense that the batch file ran.
it looked for the file x.txt but it did not find it in the folder where it was looking for. so no file was copied.
when the file location was explicitly stated, it was able to find the file and copy it.
Again, if it did nothing how do you know the bat file ran? Were the additional lines in the bat file that performed logging?
Maybe there is a problem with my configuration:
QuoteCM.OUTPUTSCRIPT is in the documentation for CA11. What I don't know is what Cognos wants for a path. Does it want something like e:\foldername\script.bat, or file://\\servername\sharename\script.bat? Are there examples available. What I have found online in the last couple hours has been useless.
What did you enter for the value of CM.OUTPUTSCRIPT?
Quote from: dougp on 13 Feb 2020 12:12:40 PM
Again, if it did nothing how do you know the bat file ran? Were the additional lines in the bat file that performed logging?
because when i changed the batch file to explicitly specify the folder location, it ran fine.
Quote from: dougp on 13 Feb 2020 12:12:40 PM
Maybe there is a problem with my configuration:
What did you enter for the value of CM.OUTPUTSCRIPT?
e:\temp\a.bat ;D 8)
Hmmm... That's what I'm using.
The documentation states that CM.OutPutLocation is mandatory if you want to save report output files in IBM Cognos software. Did you enter that parameter? Is it the same thing that appears in Cognos Configuration > Actions | Global Configuration > Archive Location File System Root?
ok i think we are getting somewhere. i encountered this in the past...
there are now 2 ways of saving a report...
1. the old way is cm.outputlocation
2. the new way is defining a file output location in Dispatchers and Services.
when you use cm.outputscript, you have to use #1. cm.outputscript will not work if with #2
The value I defined in Archive Location File System Root is:
file:///temp
and yes it also works when i use way #2.
I'm confused. Aren't #1 and #2 the same thing?
The documentation (https://www.ibm.com/support/knowledgecenter/en/SSEP7J_11.0.0/com.ibm.swg.ba.cognos.ug_cra.doc/t_asg_steps_setting_file_location.html) says to:
Open Admin Console
Configuration
Dispatchers and Services
{click on the dispatcher}
Content Manager Service > Properties
Settings
Advanced Settings > Edit...
Create a parameter named CM.OutPutLocation with a value that is the path to the directory (like e:\ReportOutput)
Create a parameter named CM.OutputScript with a value that is the path to the batch script (like e:\scripts\DoSomething.bat)
How do...
Cognos Configuration > Local Configuration > Environment > Data Access > Content Manager > Save report outputs to a file system?
...and...
Cognos Configuration > Actions | Global Configuration > Archive Location File System Root
...play into this? Does having them set create a conflict with CM.OutputScript?
Are the parameter names case-sensitive? Is the documentation correct? (OutPutLocation or OutputLocation, OutputScript or OutPutScript)
they are different. first way, this is the old one dating back to reportnet is to use cm.outputlocation and the documentation seems accurate.
the second way is to define the file System Location... you can do that using...
Ibm Cognos Administration > Configuration > Dispatchers and Services
at the upper right there are some icons... new folder, cut, paste,...etc third from the right is "Define File System Location"
you define a location and give it a name for example "Location 123"
then for example if you schedule a report to run... one of the Delivery options is to Save report as an external file...
Under that, you can find "Location 123" from the Location choices
Apparently, I've been using the second way. It requires...
Cognos Configuration > Local Configuration > Environment > Data Access > Content Manager > Save report outputs to a file system? = True
...and...
Cognos Configuration > Actions | Global Configuration > Archive Location File System Root = file://\\servername\ReportOutput
Then I...
. create subfolders in ReportOutput
. go into "Define File System Location" and alias those folders and set permissions
So now I have added CM.OutPutLocation and CM.OutputScript to the Content Manager Service advanced settings, but they don't appear to do anything.
Is there a conflict?
Does this mean that if I want to run a script, I need to roll back those updates to Cognos Configuration, and I lose the ability to have subfolders with different write permissions?
ok more info...
the second way is usually used in scheduling and running batches
the first way is when you run a report in the background and saved excel, html, etc is produced. you will get a saved html in run history as well as in the location you defined in CM.OUTPUTLOCATION. at the same time CM.OUTPUTSCRIPT is triggered when defined.
I have been running this way for years. It works for schedules and agents, as well as Run as... | Run in background...
But...
Now I wonder about the quality of the documentation and the knowledge of the consultants that set up my Cognos environment.
Pages 77-79 of the IBM Cognos Analytics Version 11.0 Administration and Security Guide (https://www.ibm.com/support/knowledgecenter/SSEP7J_11.0.0/com.ibm.swg.ba.cognos.ug_cra.doc/ug_cra.pdf) include information about this.
Saving report output files outside of IBM Cognos software
Report output files can be saved to a file system outside of IBM Cognos software. Users can choose which
output files to save.
talks about Archive Location File System Root and creating the aliases by using Define File System Locations
writes messy file names and provides no scripting options
Saving report output files in IBM Cognos Software
Users can save copies of report output files in IBM Cognos software. All report output files are saved to a
location specified in Content Manager.
uses Save report outputs to a file system = true
this mentions CM.OutPutLocation and CM.OutputScript
The two things appear to be unrelated. The first allows reports that are scheduled or run in the background to be sent to a directory on the file system. The second causes every saved "version" of a report to be also saved to the file system. Apparently the only reason I have not been duplicating all of my saved reports is I did not have CM.OutPutLocation set. (And I'm happy about that. Running out of drive space is not fun.) If that's true, it seems like I don't need Save report outputs to a file system = true.
Bummer. I was hoping I could write a script to strip off the "_en_us" from all of the file names of my report outputs and delete all of the XML files.
yup they are unrelated in the sense that they are independent of each other.
but it seems to me you can still write that script. you will just have to deal with duplicate saved reports. the easiest way is to include a delete in your batch file.
Nope. The script gets called when a copy of a report output (version) are created on the file system. It does not run when the report is sent to the file system using Run as... or a schedule and the option "Save report as external file" is used (and output is not saved as a version).
i haven't tested but if you schedule the report you can select 2 kinds of deliveries: Save report as external file and save report.
i could be wrong here but i think if you select both, it will save the report 2x as well as run the script. through the script you can then rename the file created in save report as external file provided the output folder is fixed, then delete the duplicate files.
I think I finally understand how this works. It seems less configurable, but the script picks up the rest of the configuration...
My current way (using Archive Location File System Root):
- Within the Archive Location File System Root, a folder is created for a user or business unit to write to. This is usually a junction pointing to their folder on the network. (like a shared folder or a web site folder)
- In Define File System Locations, I configure an alias to the folder and apply permissions for certain users, groups, or roles to use (write to) that alias.
- Users schedule or use "run as" to get their reports to run and write output to their location.
To replicate the functionality using CM.OutPutLocation and CM.OutputScript:
- For the folder or report in Cognos, apply permissions for certain users, groups, or roles to create versions. (write or full permission?)
- Users schedule or use "run as" to save their report output as a version of the report.
- Cognos saves a copy to the folder defined in CM.OutPutLocation.
- The script defined in CM.OutputScript runs. This script can:
- Identify which file was just created.
- Read the description (xml) file to determine the report path.
- If the report path matches a specific pattern or value, do something (like copy it to the subfolder/junction and rename it to something meaningful like the report name).
- Delete the original output file.
So the second option seems like more coding, but far more flexible. It must be a .bat file, but that can call anything (PowerShell, Windows Scripting Host, executable) to do the actual work, so batch programming isn't even needed.
Both would not be needed. If I implement CM.Output*, I'll probably clear the Archive Location File System Root box so that "Save report as an external file" disappears from the list of delivery options.
Thanks for sticking with me, Francis. This was very helpful.
glad to help