windows batch scripts

someone who left the company has write the scripts below. I have some difficulties to understands what is the script doing. I'm now doing some search in internet as well.

If anyone here expert with batch  scripts, pls share with me how the scripts works.

@echo off

setlocal ENABLEDELAYEDEXPANSION

c:
cd\
cd /d X:\prog\Minyak\fp
set _localLogMinyak=logs\getValuesFP.cmd.log.txt
set _ltools=e:\pgrs\eaars\bin\tools
echo ------------------------------------------------------------------------------------->>%_localLogMinyak%


set _ldapClientTools=C:\Program Files\OpenLDAP\ClientTools
set _lderrorlog=logs\ldapsearchFP.log.txt
set _ldapSearchFileOperations=lookup\NoStaffFP.csv
set _ldapSearchFilter=NoStaff
set _outputFile=result\eddataFP.csv

del /Q /F %_outputFile% > nul 2>&1
%_ltools%\sleep2 12
echo %time% - Start quering the ports>>%_localLogMinyak%
set /a _failcount=0

for /l %%i in (1,1,50) do (
 X:\prog\Minyak\fp\portqry.exe -n ldap.tnb.com -e 389|C:\WINNT\system32\findstr.exe "TCP port"|C:\WINNT\system32\findstr.exe /c:": LISTENING"

 echo    return: !errorlevel!>>%_localLogMinyak%
 if not !errorlevel!==0 (
  set /a _failcount+=1
 ) else (
  echo failcount: !_failcount!>>%_localLogMinyak%
  goto port_listening
 )
 echo failcount: !_failcount!>>%_localLogMinyak%
 ping 1.1.1.1 -w 1000 -n 1>nul
)
goto _ldapattrib

:port_listening
echo port_listening>>%_localLogMinyak%

:_ldapattrib
::
:: ALL _ldapattrib HAVE A BLANK SPACE AFTER THE VALUE EXCEPT THE LAST ONE
::
set _ldapattrib=employeeType 
set _ldapattrib=%_ldapattrib%tnbBusinessRegionAcronym 
set _ldapattrib=%_ldapattrib%cn 
set _ldapattrib=%_ldapattrib%tnbBusinessGroupCode 
set _ldapattrib=%_ldapattrib%tnbOrganizationChartAcronym 
set _ldapattrib=%_ldapattrib%tnbCrossCompanyManagerID 
set _ldapattrib=%_ldapattrib%tnbTerminationDate 
set _ldapattrib=%_ldapattrib%tnbPayrollCountryCode 
set _ldapattrib=%_ldapattrib%tnbMRUCode 
set _ldapattrib=%_ldapattrib%ou 
set _ldapattrib=%_ldapattrib%tnbOrganizationChart 
set _ldapattrib=%_ldapattrib%tnbBusinessUnit 
set _ldapattrib=%_ldapattrib%tnbBusinessGroup 
set _ldapattrib=%_ldapattrib%mail 
set _ldapattrib=%_ldapattrib%co 
set _ldapattrib=%_ldapattrib%tnbCrossCompanyManager 
set _ldapattrib=%_ldapattrib%NoStaff 
set _ldapattrib=%_ldapattrib%tnbStatus 
set _ldapattrib=%_ldapattrib%tnbBusinessUnitAcronym 
set _ldapattrib=%_ldapattrib%tnbStartDate 
set _ldapattrib=%_ldapattrib%tnbBusinessRegion

echo %time% - Starting ldapsearch>>%_localLogMinyak%
"%_ldapClientTools%\ldapsearch.exe" -v -c -LLL -T "X:\prog\Minyak\fp" -x -h ldap.tnb.com -b ou=People,o=tnb.com -f %_ldapSearchFileOperations% (%_ldapSearchFilter%=%%s) %_ldapattrib%>eddataFP.tmp 2>%_lderrorlog%
rem "%_ldapClientTools%\ldapsearch.exe" -v -c -LLL -T "X:\prog\Minyak\fp" -D cn=tnbedeaars,ou=Applications,o=tnb.com -w PASSWORD -H ldaps://ldap.tnb.com -b ou=People,o=tnb.com -f %_ldapSearchFileOperations% (%_ldapSearchFilter%=%%s) %_ldapattrib%>eddataFP.tmp 2>%_lderrorlog%
echo %time% - Finished ldapsearch>>%_localLogMinyak%

echo %time% - Add dummy entry>>%_localLogMinyak%
type dummy_entry_FP.txt>>eddataFP.tmp
echo %time% - Finished adding dummy entry>>%_localLogMinyak%

%_ltools%\sleep2 2
echo.>>%_localLogMinyak%
echo %time% - Starting LDIFtoCSV>>%_localLogMinyak%
dir >>%_localLogMinyak%
LDIFtoCSV.exe -M 8 -F $ -o %_outputFile% -l logs\LDIFtoCSVFP.exe.log eddataFP.tmp
%_ltools%\sleep2 2
del /Q /F X:\prog\Minyak\fp\eddataFP.tmp
rem del /q /f X:\prog\Minyak\fp\lookup\NoStaffFP.csv
echo %time% - Finished LDIFtoCSV>>%_localLogMinyak%
echo.>>%_localLogMinyak%
dir >>%_localLogMinyak%
dir X:\prog\Minyak\fp\result >>%_localLogMinyak%

::


:: type %_lderrorlog%

:eof
echo %time% - END >>%_localLogMinyak%
exit

Open in new window

motioneyeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Darrell PorterEnterprise Business Process ArchitectCommented:
It would appear to be using Microsoft's Port Query utility to resolve an internal Thomas & Betts LDAP server, ldap.tnb.com, then determine if that server is listening on LDAP port 389 with the command:

 X:\prog\Minyak\fp\portqry.exe -n ldap.tnb.com -e 389|C:\WINNT\system32\findstr.exe "TCP port"|C:\WINNT\system32\findstr.exe /c:": LISTENING"

Open in new window


If this command does not result in an error, it will copy a text string to the logfile and perform an LDAP search using OpenLDAP's ldapsearch.exe in the People Organization Unit based on this criteria:

:: ALL _ldapattrib HAVE A BLANK SPACE AFTER THE VALUE EXCEPT THE LAST ONE
::
set _ldapattrib=employeeType 
set _ldapattrib=%_ldapattrib%tnbBusinessRegionAcronym 
set _ldapattrib=%_ldapattrib%cn 
set _ldapattrib=%_ldapattrib%tnbBusinessGroupCode 
set _ldapattrib=%_ldapattrib%tnbOrganizationChartAcronym 
set _ldapattrib=%_ldapattrib%tnbCrossCompanyManagerID 
set _ldapattrib=%_ldapattrib%tnbTerminationDate 
set _ldapattrib=%_ldapattrib%tnbPayrollCountryCode 
set _ldapattrib=%_ldapattrib%tnbMRUCode 
set _ldapattrib=%_ldapattrib%ou 
set _ldapattrib=%_ldapattrib%tnbOrganizationChart 
set _ldapattrib=%_ldapattrib%tnbBusinessUnit 
set _ldapattrib=%_ldapattrib%tnbBusinessGroup 
set _ldapattrib=%_ldapattrib%mail 
set _ldapattrib=%_ldapattrib%co 
set _ldapattrib=%_ldapattrib%tnbCrossCompanyManager 
set _ldapattrib=%_ldapattrib%NoStaff 
set _ldapattrib=%_ldapattrib%tnbStatus 
set _ldapattrib=%_ldapattrib%tnbBusinessUnitAcronym 
set _ldapattrib=%_ldapattrib%tnbStartDate 
set _ldapattrib=%_ldapattrib%tnbBusinessRegion

Open in new window


Overall, it appears the script ensures it can talk to the LDAP server, performs a targeted query against the LDAP server, and compares the results of that LDAP query to the contents and outputs the results to the directory X:\prog\Minyak\fp\result.

Do you need a line-by-line analysis of the scripts?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
motioneyeAuthor Commented:
Hi WalkaboutTigger
If you could with line by line basis analysis, I really appreciate that, I knew some of the parts of the scripts but 2nd opinion I guess make me more confident
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.