pravinwalimbe
21st December 2006, 15:16
Hi all,
I have crated one batch file (batch.bat) and copied it on server. This batch file serches for perticular file on server,if it get that rename it with date concat.and if it is not there create new file with file name &current date.
Now i am running this file through session using
fp = run.prog("cmd.exe","/c :\export\batch.bat",RP_WAIT)
Return value is zero.
But i am not getting the result.means its not renaming or creating a new file.
attched herewith is my batch file code.

mr_suleyman
21st December 2006, 15:29
Did you check user and file permissions on server ? Does it works manually ?

george7a
21st December 2006, 16:32
Hi,

I think you should specify the full path in the destination of the copy/rename command. Also the extension in the rename was missing. I attached the fixed batch file.

Also make sure the source of the copy command does exist.

- George

pravinwalimbe
22nd December 2006, 07:39
Hi all
Thanks for your tips,but still not getting the results.
I gave the full path in the destination of copy and rename commmands.Also I have full permission for the file on server.
Its working manually. What could be the problem?
Thanks in advance.

george7a
22nd December 2006, 08:56
Hi,

I have noticed one more thing. You will need to add "cmd" before the "/c" in the run.prog argument (also you had an extra ":" in your code).
run.prog("cmd.exe", "cmd /c "&FULL.SERVER.BATCH.PATH,RP_WAIT)
| an example for FULL.SERVER.BATCH.PATH = "d:\export\batch.bat"
I hope it helps,

- George

pravinwalimbe
22nd December 2006, 12:22
Hi george,
I made the changes suggested by you,but still not getting the result.
In the batch file it is accepting the path of my mapped drive and manually executing successfully.But when i am giving the path of server where batch file actually located its not executing.
In my Baan session i have given the server path and return value of run.prog is zero but file is not created.

george7a
22nd December 2006, 12:25
Hi,

Can you please post the exact code that you are using now?

- George

pravinwalimbe
22nd December 2006, 12:44
Hi
Following is the my batch file code.
for /F "tokens=2,3,4 delims=/ " %%i in ('date/t') do set d=%%k%%i%%j
if exist d:\export\sox\userhistory.txt (rename d:\export\sox\userhistory.txt d:\export\sox\%d%_%userhistory.txt)
if not exist d:\export\sox\format.txt (copy d:\export\sox\format.txt d:\export\sox\%d%_%userhistory.txt)

here d:\export\sox\fname is path of file on server.


And in Baan session

choice.cont.process:
on.choice:

read.main.table()
functions:

function read.main.table()
{
fp = run.prog("cmd.exe","cmd /c d:\export\sox\test.bat",RP_WAIT)
}

Please suggest.

suhas-mahajan
22nd December 2006, 13:07
Hi Pravin,

Can you please change /c to /k and check it out?

Ex.
ret = run.prog("cmd.exe","/k d:\test.bat ", RP_NOWAIT)
suspend(50)


regards,

-Suhas

george7a
22nd December 2006, 13:18
Hi,

Use the attach batch. The rename destination should be without full path.

I have tried it in our NT System and it works!

If you say it works manually it should work from the script too. If not try to run any other exe(notpad/calc) you have on the server to make sure the function is working good.

- George

suhas-mahajan
23rd December 2006, 08:34
Hi Pravin,

Seems the issue is still pending.

Ok..Can you specify Universal Naming Convention (UNC) notation for the server and share name, rather than a remote drive letter ex. \\server\share

Please let me know results.

regards,

-Suhas

pravinwalimbe
26th December 2006, 08:35
Hi Suhas,
I followed your suggestion,but I am not getting the success. When i am runing manully my batch file, its working fine.But by using Baan session (run.prog), I am getting the return value as zero but its not creating the file.
For your reference I am attaching my batch file and Baan script.
Please suggest whrere I am going wrong.
Thanks in advance.

suhas-mahajan
26th December 2006, 09:17
Ok, Start step-by-step:

1. Create a new batch file by entering dir > sample.txt command and try to run it through run.prog.

2. Or just check the environment variables are creating or not.

3. Check this pc is accessing from start > run command of your server.

4. Enter pause command into your batch file and check cmd is in your task manger > processes.

5. Or concatenate commands through shell command tricks by joining "&" sign instead of creating batch file.

Come back with results.

regards,

-Suhas

pravinwalimbe
26th December 2006, 12:06
Hi,
My PC is accssing the cmd.exe from local drive i.e.
c:\WINNT\system32\cmd.exe, and not from server. Is this may be the problem? Because if I run batch file manually its working fine.

I tried the concatenate command option but i dont think its feasible.

Please suggest.

suhas-mahajan
26th December 2006, 12:38
Hi Pravin,

run.prog works at server side. How you concluded it is running from client side?

You can use app_start() for running programs at client side.

Did you checked my other tips?

regards,

-Suhas

pravinwalimbe
27th December 2006, 09:28
Hi
Thanks all,it work finally.
The changes i made are :
I used the UNC notation suggested by Suhas in batch file for noth source and destination of copy command.
and in run.prog made the following changes.

run.prog("\\172.30.5.45\export\test.bat","",RP_WAIT)