Page 1 of 1

Execute command problem

Posted: Thu May 22, 2014 6:01 am
by beber005
Hi everyone,

Yesterday I posted in the forum a problem. This one was about "how to copy a file after another one" I mean the content. For this I'm trying to use Execute command to use windows command. My code is as follows :

Code: Select all

vFileName1 = 'Y:\1-ENTREE\ImportSAP\Toto1.csv';
vFileName2 = 'Y:\1-ENTREE\ImportSAP\Toto2.csv';
vCmd = 'copy ' | vFileName1 | ' ' | vFileName2 ;
ExecuteCommand (vCmd,0);
But TM1 says "Error: Prolog procedure line (52): The system cannot find the file specified." and I don't know how.At first I wanted to use the vbscript but I do not know if this is possible

Code: Select all

Set objFSO = CreateObject("Scripting.FileSystemObject")
    If objFSO.FileExists("C:\test.txt") Then
    objFSO.CopyFile "C:\test.txt" , "C:\test2.txt"
    Else
    MsgBox "Fichier C:\test.txt introuvable", vbExclamation
    End If
    Set objFSO = Nothing
Thanks a lot for your help :D

Re: Execute command problem

Posted: Thu May 22, 2014 6:21 am
by declanr
I'm guessing the Y drive is one mapped on your pc, if it isnt mapped on the server then executing a command from the server wont find it. If thats the case you can map the Y drive on the server but preferably use the real path anyway.

To test it log onto the server as the account tm1/cx runs under and try and use the cmd prompt manually, when that works throw it into TI.

Re: Execute command problem

Posted: Thu May 22, 2014 6:44 am
by beber005
Actually you're right, the path that I gave was not supported by the server, so I changed this but it always returns me the same error localization file. In addition, I can not use the command prompt as administrator I am not my PC. Do you think it am because of that I can not use the command in TM1?

Re: Execute command problem

Posted: Thu May 22, 2014 7:05 am
by beber005
Okay I find a solution by using the file .bat to execute my windows CMD and it's working perfectly :)

Re: Execute command problem

Posted: Thu May 22, 2014 8:13 am
by Sebastian.Klein
I guess if you are using cmd /c copy .... as the command you would execute, it should work also. But executing a Batch-Script is also a good way :-)

Re: Execute command problem

Posted: Thu May 22, 2014 8:53 am
by dan.kelleher
Hi Beber,

One reason for this might be because TM1 still has the file open until it completes the tab that is writing to it. The file is actually named C:\test.txt$ until the tab code is complete. If you have TextOutput or ASCIIOutput in your prolog, try concatenating the files in the Epilog. This may not be the reason, but worth pointing out in this thread.

Having said that, I have also come across instances where the ExecuteCommand([my operation]) fails, and the solution is always to write [my operation] to a .bat, and execute the .bat via ExecuteCommand().

Thanks,

Dan