'cmd' is not recognized as an internal or external command - while importing
Hi,
I am trying to use a bat script to import in a list. When I manually enter username and password in the script, it works fine but when I change it to read it from a .txt file, it shows the error: "'cmd' is not recognized as an internal or external command, operable program or batch file.". It's not like there is an error in reading from the .txt file. The user details are being picked up and the credentials are being formed as required by the connect script. Posting the codes below for better understanding:
Manually entered Username and Password: -- working
@Echo off
set AnaplanUser="Username:Password"
set WorkspaceId=<hidden>
set ModelId=<hidden>
set ServiceUrl="https://api.anaplan.com"
set AuthUrl="https://auth.anaplan.com"
set FileName="Trial Import.csv"
set FilePath="C:\Users\dishanka518\Documents\Anaplan_Connect\Files\Trial Import.csv"
set ImportName="Import Trial"
set DumpName="C:\Users\dishanka518\Documents\Anaplan_Connect\Error Dump\Trial Import.csv"
set Chunksize=1
set Operation=-debug -service %ServiceUrl% -auth %AuthUrl% -workspace %WorkspaceId% -model %ModelId% -chunksize %Chunksize% -file %FileName% -put %FilePath% -import %ImportName% -execute -output %DumpName%
rem *** End of settings - Do not edit below this line ***
setlocal enableextensions enabledelayedexpansion || exit /b 1
cd %~dp0
if not %AnaplanUser% == "" set Credentials=-user %AnaplanUser%
set Command=.\AnaplanClient.bat %Credentials% %Operation%
@Echo %Command%
cmd /c %Command%
pause
Importing while taking user details from a file: --- not working
@Echo off
@Echo off
set /A i=0
set path=""
set /A n=0
REM Reading from user detail File
set "file=C:\Users\username\Documents\Anaplan_Connect\Data\System Files\UserDetails.txt"
for /F "usebackq delims=" %%a in ("%file%") do (
set /A i+=1
call set user_arr[%%i%%]=%%a
call set n=%%i%%
)
REM Forming Anaplan Username:Password
set userid=%user_arr[1]%:%user_arr[2]%
REM Import Data into Anaplan
set AnaplanUser="%userid%"
set WorkspaceId=<hidden>
set ModelId=<hidden>
set ServiceUrl="https://api.anaplan.com"
set AuthUrl="https://auth.anaplan.com"
set FileName="Trial Import.csv"
set FilePath="C:\Users\username\Documents\Anaplan_Connect\Files\Trial Import.csv"
set ImportName="Import Trial"
set DumpName="C:\Users\username\Documents\Anaplan_Connect\Error Dump\Trial Import.csv"
set Chunksize=1
set Operation=-debug -service %ServiceUrl% -auth %AuthUrl% -workspace %WorkspaceId% -model %ModelId% -chunksize %Chunksize% -file %FileName% -put %FilePath% -import %ImportName% -execute -output %DumpName%
rem *** End of settings - Do not edit below this line ***
setlocal enableextensions enabledelayedexpansion || exit /b 1
cd %~dp0
if not %AnaplanUser% == "" set Credentials=-user %AnaplanUser%
set Command=.\AnaplanClient.bat %Credentials% %Operation%
@Echo %Command%
cmd /c %Command%
pause
Answers
-
@Dishank I am not an expert in batch scripting, however I would suggest to check the run the code in debug mode and check the value "userid" before assigning it to "AnaplanUser" variable.
I just googled for how to read a file in batch script and found a link: https://www.tutorialspoint.com/batch_script/batch_script_reading_from_files.htm which might be helpful to consider.
AB
0