July 23, 2009 at 3:50 pm
I posted this Q on General on Programming, but no reply so I'm posting here.
I'm not an expert in batch scripting. I'm trying to do robocopy of two .sls files on a remote server using .bat files. I'm calling the .bat files remotely using PSEXEC utility. When I call the batch file using PSEXEC it is failing to check the IF condition in the batch file but if I execute the same batch file on local, it is executing as expected.
Below I copied code and output, can someone correct me if I'm doing wrong anywhere?
Batch script. (this is a test script)
---------------------
@ECHO OFF
:Start1
REM Echo ***************************
Echo * Copying FNPRD1.SLS file *
REM Echo ***************************
FOR %%G IN (D:\Incoming\ABCSRVR\FNPRD1.SLS) DO (
IF EXIST FNPRD1.SLS (
echo File %%G Found
) ELSE (
ECHO File %%G Not Found
SLEEP 1
GOTO :Start1
)
)
REM Echo ***************************
Echo * Copying FNPRD2.SLS file *
REM Echo ***************************
:Start2
FOR %%G IN (D:\Incoming\ABCSRVR\FNPRD2.SL1) DO (
IF EXIST FNPRD2.SL1 (
echo File %%G Found
) ELSE (
ECHO File %%G Not Found
SLEEP 1
GOTO :Start2
)
)
PSEXEC output (When i call the batch file remotely).
------------------------------------------------------
C:\Documents and Settings\ABC>PSEXEC \\BEL-APPRS01 d:\incoming\ABCSRVR\test2.bat
PsExec v1.94 - Execute processes remotely
Copyright (C) 2001-2008 Mark Russinovich
Sysinternals - http://www.sysinternals.com
* Copying FNPRD1.SLS file *
File D:\Incoming\ABCSRVR\FNPRD1.SLS Not Found
* Copying FNPRD1.SLS file *
File D:\Incoming\ABCSRVR\FNPRD1.SLS Not Found
* Copying FNPRD1.SLS file *
File D:\Incoming\ABCSRVR\FNPRD1.SLS Not Found
* Copying FNPRD1.SLS file *
File D:\Incoming\ABCSRVR\FNPRD1.SLS Not Found
* Copying FNPRD1.SLS file *
File D:\Incoming\ABCSRVR\FNPRD1.SLS Not Found
^C
* Copying FNPRD1.SLS file *
Local output (when I call the batch file in the local folder)
-------------------------------------------------------
D:\Incoming\ABCSRVR>test2
* Copying FNPRD1.SLS file *
File D:\Incoming\ABCSRVR\FNPRD1.SLS Found
* Copying FNPRD2.SLS file *
File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found
File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found
File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found
File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found
File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found
File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found
File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found
File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found
^CTerminate batch job (Y/N)? y
Quick reply highly appreciated...
thanks
Jay.
Thanks
Jay
http://www.sqldbops.com
July 23, 2009 at 3:55 pm
Did it occur that maybe noone knows what PSEXEC is and that is why noone has tried to answer your question?
I have a guess, it has something to do with PeopleSoft, what I don't know.
July 23, 2009 at 4:15 pm
I hope PSEXEC is known tool to everybody, anyway PSEXEC is a tool which helps execute processes romotely.
Eg. if I wants to start/stop a service in a remote server from my desktop or a different server, i can use PSEXEC to do that. the below link from Microsoft will clarify more.
http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx
Thanks
Jay
http://www.sqldbops.com
July 23, 2009 at 4:17 pm
Not something I use or have heard about.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply