executecommand() with batch files

User avatar
Cam
Posts: 18
Joined: Wed Mar 09, 2011 12:30 am
OLAP Product: TM1
Version: 9.5.1
Excel Version: 2003

executecommand() with batch files

Post by Cam »

Hello,

We developed a TI process to trigger a .bat that copies files from one network path to the TM1 Server. It always displays a succesful msg box, but it never do anything, we suspect is a permissions problem, but we are not sure, because we can execute the file and it works.

Is there a way to see what's happening, why the process never executes. (debug option on tm1server.log can work?)

We tried cmd /c option, pointing to the location (D:\etc), executing with a user, executing with a chore, etc. Maybe we are not understanding how this function works and what permit we need to grant (documentation is little for this "powerful" TI function).

Any help will be good..

Thanks

Cam
tomok
MVP
Posts: 2836
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: executecommand() with batch files

Post by tomok »

Remove the /c option and re-run the process. This should leave the box open and you will be able to see whatever message the system returned. You will probably have to login to the desktop of the TM1 server with the TM1 service account ID in order to see the command window though.dialog box
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
dubs
Posts: 131
Joined: Fri May 22, 2009 10:43 am
Version: 9.4
Excel Version: 2003

Re: executecommand() with batch files

Post by dubs »

put a pause in the batch file to keep the dos window open and see if you get any errors coming up
User avatar
qml
MVP
Posts: 1096
Joined: Mon Feb 01, 2010 1:01 pm
OLAP Product: TM1 / Planning Analytics
Version: 2.0.9 and all previous
Excel Version: 2007 - 2016
Location: London, UK, Europe

Re: executecommand() with batch files

Post by qml »

... or put " > C:\myfile.txt" at the end of your command to print anything the OS says to a text file.
Kamil Arendt
User avatar
Cam
Posts: 18
Joined: Wed Mar 09, 2011 12:30 am
OLAP Product: TM1
Version: 9.5.1
Excel Version: 2003

Re: executecommand() with batch files

Post by Cam »

The problem is that we dont see the command window.. is so fast in messaging "successful".. (permits issue??)

We tried this on the server and on clients.
ajain86
Community Contributor
Posts: 132
Joined: Thu Oct 15, 2009 7:45 pm
OLAP Product: TM1
Version: 9.4.1 9.5 9.5.1
Excel Version: 2003 2007

Re: executecommand() with batch files

Post by ajain86 »

from my experience, executecommand(), does not return anything back to TM1 (except that it had completed) and therefore TM1 always says a message successful.

My thinking was that the function just executed the .bat file and did not have any connection to it. The only thing it can do is wait for the script to finish to return back to TM1.

Are you able to just run the script directly without using TM1?
Also, I would second both options of putting a pause and/or exporting the command text to a file.

Are you giving the proper path for the script in TM1. You will need to give the full path it the script is outside the TM1 Data directory.
Ankur Jain
tomok
MVP
Posts: 2836
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: executecommand() with batch files

Post by tomok »

Cam wrote:The problem is that we dont see the command window..
Did you not even bother to read any of the suggestions????? Every one of them is giving you directions on how you can either keep the command window open, or capture the command window results to a text file, SO THAT YOU CAN SEE THE RESULTS!!! It doesn''t matter how fast the TI process if you follow one of these suggestions.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
User avatar
Steve Vincent
Site Admin
Posts: 1054
Joined: Mon May 12, 2008 8:33 am
OLAP Product: TM1
Version: 10.2.2 FP1
Excel Version: 2010
Location: UK

Re: executecommand() with batch files

Post by Steve Vincent »

Cam wrote:The problem is that we dont see the command window.. is so fast in messaging "successful".. (permits issue??)

We tried this on the server and on clients.
Where you try it from is irrelevant, it will always do the same thing.

Anything you ask a TM1 service to do outside of TM1 itself will run using the same account permissions that the service is running under. You have to think like that account to be able to figure out what it is doing.

Imagine you have a local windows account called "TM1service" and all your TM1 models run as a service using this accounts' credentials. If you ask TM1 to run a bat file using a file path D:\windows then the TM1service account must have D: mapped and be granted the required permissions. Windows being the 1st class pain in the rear that it is will make that harder and more complicated when you start refering to data on other machines within the network. The main rule is to always use the UNC path and not local drive names. That removes one possible area for issues, the other is that Windows security policies insist that the account making the request for data on another server must also exist on that other server. Not only that, each local account must also have the same password. If not, they won't authenticate and the bat will probably output a file not found type of error.

Log in locally to the windows server as the account that runs your TM1 services. Then add the pause to the bat as suggested and run it. You should then see the errors TM1 is seeing and it should help you track down the problem.
If this were a dictatorship, it would be a heck of a lot easier, just so long as I'm the dictator.
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet
User avatar
Cam
Posts: 18
Joined: Wed Mar 09, 2011 12:30 am
OLAP Product: TM1
Version: 9.5.1
Excel Version: 2003

Re: executecommand() with batch files

Post by Cam »

Hello,

Sorry tomok, i did try that, we are analyzing all the answers, is interesting what Steve wrote, i try to do my best to understand :roll: which is expert advice like all of you.

On the Reference Guide
------------
ExecuteCommand
This is a TM1 TurboIntegrator function, valid only in TurboIntegrator processes.

This function executes a command line during a process. You can use ExecuteCommand to run a desktop application, but not a service
------------
this means tm1 cant executecommand() to open services, or not works when TM1 is runt as a service? We are running TM1 as a service.

Thanks,
dubs
Posts: 131
Joined: Fri May 22, 2009 10:43 am
Version: 9.4
Excel Version: 2003

Re: executecommand() with batch files

Post by dubs »

Cam I think what you need to do is forget about TM1 until the batch files works when executing manually outside of TM1, once you are confident it works then try executing it from TM1, otherwise it can be too hard to see what is going on, if it works outside tm1 but not inside tm1 it immediately narrows the possibilities of what is going wrong (and I would check permissions first)
User avatar
wissew
Posts: 54
Joined: Tue Jun 17, 2008 7:24 pm
OLAP Product: TM1
Version: 9.5.2; 10.2.2; 11
Excel Version: 2003 SP3 - 2013
Location: Beaverton, OR

Re: executecommand() with batch files

Post by wissew »

dubs wrote:Cam I think what you need to do is forget about TM1 until the batch files works when executing manually outside of TM1, once you are confident it works then try executing it from TM1, otherwise it can be too hard to see what is going on, if it works outside tm1 but not inside tm1 it immediately narrows the possibilities of what is going wrong (and I would check permissions first)

dubs has got you going in the right direction. Remember the tm1 server account needs to be logged on to the desktop and the drives involved should be mapped by the account. If it works when you execute it off the server desktop logged in under the TM1 service account it should work from TI. The only problems I have had is when there are conflicting bat file running on the server (ie a back job).
User avatar
Cam
Posts: 18
Joined: Wed Mar 09, 2011 12:30 am
OLAP Product: TM1
Version: 9.5.1
Excel Version: 2003

Re: executecommand() with batch files

Post by Cam »

A little late, but we solved it, mainly permissions issues on my TM1 Service account (access to log on the server). Now copying files from different servers works quite well. This function is pretty useful, we prefered to use variables instead of batch files so we can add parameters.

Thanks for the help!
l_kothamasu
Posts: 10
Joined: Thu Oct 07, 2010 1:55 am
OLAP Product: IBM Cognos TM1
Version: 10.2.2 Fix pax 4
Excel Version: 2013

Re: executecommand() with batch files

Post by l_kothamasu »

Hi Cam,
If you don't mine, could you please let me know how you solved this issue? Currently, I am also facing similar kind of issue, which means batch files are working manually, but when I used EXECUTECOMMAND() in TM1 to fetch the batch files then it's not working and message populates as "TM1 executes successfully". I have many ways, but still not working.
Thanks in advance.
User avatar
qml
MVP
Posts: 1096
Joined: Mon Feb 01, 2010 1:01 pm
OLAP Product: TM1 / Planning Analytics
Version: 2.0.9 and all previous
Excel Version: 2007 - 2016
Location: London, UK, Europe

Re: executecommand() with batch files

Post by qml »

Have you tried any of the methods suggested in this thread to find out what message the OS is returning? There are a few possible reasons for this problem and yours isn't necessarily the same as Cam's.
Kamil Arendt
whitej_d
Community Contributor
Posts: 103
Joined: Mon Sep 05, 2011 11:04 pm
OLAP Product: TM1
Version: 10.2
Excel Version: 2010

Re: executecommand() with batch files

Post by whitej_d »

Hi,

You need to make sure the TM1 service account has the relevant permissions to the location on the network. Then you need to restart the TM1 service to apply any new windows security rights to the service.

For some reason any new rights granted to a windows user only take effect when the service is restarted. You'll find it works manually when logged on as the user (after logging off and on again once the security rights have been granted), but not via TI until the service has been restarted.
l_kothamasu
Posts: 10
Joined: Thu Oct 07, 2010 1:55 am
OLAP Product: IBM Cognos TM1
Version: 10.2.2 Fix pax 4
Excel Version: 2013

Re: executecommand() with batch files

Post by l_kothamasu »

Hi,

Thanks for your reply (white and QML)

- When I execute batch files manually (which means just double click the batch files) then I am receiving emails (One for successful and another for Unsuccessful) to my account.
- When I had written the below coding in Prolog tab (5 different ways) then I am not receiving any email to my account. Here I am planning to write the coding as If condition to satisfy only one batch files (successful or unsuccessful). Please see below coding:
WAY 1:
-------
§ No Data source
§ No Variable declaration
§ In Epilog Tab
vResult = 0;
set = EXECUTEPROCESS('Process_Name');
IF (set = ProcessExitNormal());
vResult = 1;
ENDIF;
IF(vResult = 1);
# If it success
vCommandLine = 'E:\path of success.bat';
ELSE;
# If it failed
vCommandLine = 'E:path of failure.bat';
ENDIF;
ExecuteCommand(vCommandLine, 0);

WAY 2:
-----------------
§ No Data source
§ No Variable declaration
§ In Epilog Tab
return_Value = ExecuteProcess('Process_Name');
IF(return_Value = ProcessExitSeriousError() );
#If it failed
vCommandLine = 'E:path of failure.bat';
ELSE;
# If it failed
vCommandLine = 'E:path of success.bat';
ENDIF;
ExecuteCommand(vCommandLine, 0);

Way 3:
----------------
vResult = 0;
set = EXECUTEPROCESS('process 1');
IF (set = ProcessExitNormal());
vResult = 0;
ENDIF;
IF(vResult <> 0);
# SUCCESS
vSuccess = 'E:path of success.bat';
ExecuteCommand(vSuccess,0);
ELSE;
# FAILED
vFailure = 'E:path of failure.bat';
ExecuteCommand(vFailure,0);
ENDIF;

Way 4:
----------------
vResult=0;
pcube = 'cube_Name';
set1 = EXECUTEPROCESS('Process_NameOne');
CELLPUTS(TIMST(NOW, '\Y \M \d \h:\i:\s'), pcube,'process_NameOne', 'Time');
IF(set1=ProcessExitNormal());
CELLPUTN(1,pcube,'process_NameOne','Count');
ENDIF;
set2 = EXECUTEPROCESS('Process_NameTwo');
CELLPUTS(TIMST(NOW, '\Y \M \d \h:\i:\s'), pcube, 'process_NameTwo', 'Time');
IF(set2=ProcessExitNormal());
CELLPUTN(1,pcube,'process_NameTwo','Count');
ENDIF;
IF(CELLGETN('cube_name','All','Count')=2);
vResult=1;
ENDIF;
IF(vResult =1);
# If it success
vCommandLine = 'E:path of success.bat';
ELSE;
# If it Failed
vCommandLine = 'E:path of failure.bat';
ENDIF;
ExecuteCommand(vCommandLine,0);

Way 5:
-------------------------------
- In prolog tab or Epilog tab (Tried on both tabs)
Executecommand(‘E:path of successful.bat’, 0);

Note: All coding is working and getting message as "Process Executed successfully", but I am not receiving any email. I am Testing this coding in TM1 Development server as a Admin user access. So, I think it would be a permission issue or security issue, If it is a any of the these causes, can some one please update what kind of security should i need to double check.

Thanks in advance.
whitej_d
Community Contributor
Posts: 103
Joined: Mon Sep 05, 2011 11:04 pm
OLAP Product: TM1
Version: 10.2
Excel Version: 2010

Re: executecommand() with batch files

Post by whitej_d »

Hi,

Go through these exact steps:

1. Check your windows services (on the server) to see what username TM1 is running under. If it's local system, then change it to a named user.
2. Log into the server as the user which is running TM1.
3. Try running your batch file manually while logged in as the TM1 Service user. If it doesn't work as expected, then change the security settings for the TM1 service user to allow you to run it successfully. It will probably need execute rights to the folder where the bat file is stored, but also read/write rights as appropriate for any file copy/move that takes place in the bat.

4. Log out and log back in to Windows as the TM1 service user to apply the new security rights. Check you can manually execute the batch file.
5. Restart the TM1 service.

Now you should be able to successfully run the batch process from the TI.
l_kothamasu
Posts: 10
Joined: Thu Oct 07, 2010 1:55 am
OLAP Product: IBM Cognos TM1
Version: 10.2.2 Fix pax 4
Excel Version: 2013

Re: executecommand() with batch files

Post by l_kothamasu »

Hi White,

I tried as per below instructions, but still I am not able to receive any email if run TI process (I tested by restarting the server and I checked the TM1 users access (It is Admin user to execute TI process). Is there any other way to rectifify this issue?

Thanks in advance.

Regards,
rmackenzie
MVP
Posts: 733
Joined: Wed May 14, 2008 11:06 pm

Re: executecommand() with batch files

Post by rmackenzie »

l_kothamasu wrote:I checked the TM1 users access (It is Admin user to execute TI process).
The advice is to check the the name of the account that the TM1 service is running under. If this isn't your account then there may be a permissions issue where by you can run a batch file to send an e-mail, but the account running the TM1 service cannot. It's not anything to do with whether a user is an Admin within TM1. Some common accounts used to run services have different permissions which is why whitej_d is advising you to change the service account to your own in order to propertly test the batch files.

To check the account that the TM1 service is running under you need to goto the Services console (run services.msc from Start->Run) on the server where TM1 is running. Find the service, right-click and somewhere in the Properties option it will tell you what account.

If you don't have access to the TM1 server then you might have to ask someone in your IT department to help you with this.
Robin Mackenzie
User avatar
yyi
Community Contributor
Posts: 122
Joined: Thu Aug 28, 2008 4:42 am
Location: Sydney, Australia

Re: executecommand() with batch files

Post by yyi »

vCommandLine = 'E:\path of success.bat';
also noticed that your command line doesn't have "cmd /c " before the "E:\*.bat"
i found on my instance, it needs the prefix before the path & bat file name
Yeon
Post Reply