Unable to start Zookeeper server in stand alone mode - apache-zookeeper

I am unable to start Zookeeper server in stand alone mode. Getting below error :
C:\Users\user\AppData\Local\Programs\apache-zookeeper-3.5.6\bin>call "-Dzookeeper.log.dir=C:\Users\user\AppData\Local\Programs\apache-zookeeper-3.5.6\bin..\lo
gs" "-Dzookeeper.root.logger=INFO,CONSOLE" "-Dzookeeper.log.file=zookeeper-user-server-USER-PC.log" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cm
d /c taskkill /pid %%p /t /f" -cp "C:\Users\user\AppData\Local\Programs\apache-zookeeper-3.5.6\bin..\build\classes;C:\Users\user\AppData\Local\Programs\apache-
zookeeper-3.5.6\bin..\build\lib*;C:\Users\user\AppData\Local\Programs\apache-zookeeper-3.5.6\bin..*;C:\Users\user\AppData\Local\Programs\apache-zookeeper-3.
5.6\bin..\lib*;C:\Users\user\AppData\Local\Programs\apache-zookeeper-3.5.6\bin..\conf" org.apache.zookeeper.server.quorum.QuorumPeerMain "C:\Users\user\AppDa
ta\Local\Programs\apache-zookeeper-3.5.6\bin..\conf\zoo.cfg"The filename, directory name, or volume label syntax is incorrect.

The filename, directory name, or volume label syntax is incorrect.
check these things in you config file
C:\Users\user\AppData\Local\Programs\apache-zookeeper-3.5.6\bin..\lo gs
what's the .. for?
and it would be better to aviod using '.' in windows system.

Related

Batch file explore directory for PostgreSQL connection

Once again, I am asking for your help to manage a small batch script.
As announced, in a previous post, I'm used to work on linux and automation tasks are more obvious to me but I have to work today under Microsoft environment.
Writting a Batch file is definitly not an easy things.
I am able with this script to be connected to a PostgreSQL database and load data via ogr2ogr. Until then, no problem.
Currently, the path of the folder is hard written in my code, but I would like to have the possibility of choosing the working directory through windows explorer.
Also, concerning this directory, I would like to have the possibility to process the subfolders at the same time.
Here, below the piece of my *.bat code:
TITLE Upload Shapefile Files to PostgreSQL
#echo off
cls
color 9
echo ******************************************************************************
echo * Upload Shapefile Files to PostgreSQL *
echo ******************************************************************************
set /P Host=Please enter your Server Host (default:localhost):
set /P Port=Please enter your PGSQL port (default:5432):
set /p Database=Please enter your PGSQL Database Name (default:postgres):
set /P Schema=Please enter your Edigeo Schema (default:public):
set /P User=Please enter your PGSQL username (default:postgres):
set /P Password=Please enter your PGSQL password (default:postgres):
For /F %%H In ("C:\Users\stephj\Desktop\SHP\*.shp") do ogr2ogr -overwrite -t_srs EPSG:2154 -s_srs EPSG:2154 -f "PostgreSQL" PG:"host=%Host% port=%Port% user=%User% password=%Password% dbname=%Database%" -lco schema=%Schema%
pause
Thanks in advance for your time and your help.
Ok, here is a way. This will just demonstrate by echoing the files, you need to amend it to follow your command structure:
Note!! This is a batch/PowerShell hybrid script. It needs to be saved with a batch file extension, preferably .cmd:
#echo off
set "pshell="(new-object -COM 'Shell.Application').BrowseForFolder(0,'Select Folder',0,0).self.path""
for /f "delims=" %%a in ('powershell %pshell%') do set "workdir=%%a"
for /r "%workdir%" %%i in (*.shp) do echo "%%~i"

Assist with batch file that searches and xcopy hidden file to specific dir

It's annoying to manually always search in the CMD and xcopy the hidden file, can someone whos good in scipting help me out?
I use these 2 commands:
Firstly i open CMD in the FOLDER2 and entering this command to find the hidden file in the hidden random sub dir:
dir /s /b | find "robotknow"
(robotknow is not the fullname of the file, only part of it.)
And then when it find the hidden file within the random made subdir i copy the whole path including the whole filename with the ending.
Xcopy /h *The whole path including the filename and ending* C:\hello
My folders:
$sourceDir = 'C:\Users\USER\AppData\Local\Packages\FOLDER1\FOLDER2'
$targetDir = 'C:\hello'
So i wish to create a batch that could search that string "robotknow" and copy the fullname of the file to my tagetdir.
Is it possible?
Im trying to learn commands but batching is harder, if i was unclear on anything please ask me thank you!
Edit:
I found few commands that could be useful but I dont know how to use them so that it works.
$searchStrings = For it to search after the string above i mentioned: "robotknow"
And
Copy-Item $_.FullName $targetpath
An example would be:
The filename has this in it's name "robotknow" and i want to copy it.
Copy the file im searching after to copy thats within the sub folder of the FOLDER2 which is an hidden random folder that i cannot se:
%LocalAppData%\Packages\FOLDER1\FOLDER2\THE-hidden-RANDOM-made-sub-DIR.
Copy it to it's final directory c:\hello
The final directory, simply just: c:\hello.
By hidden i mean that i cannot see in file explorer, windows GUI and neither if i put this simple command in CMD dir to show the hidden random folder where the file is located in, they are not showing.
The file only appears in CMD if i enter this command dir /s /b | find "robotknow" when im in the FOLDER2.
Only after that i can se the hidden random made dir/folder and the full hidden path to it (the file).
I suggest following batch file code for this task:
#echo off
setlocal EnableExtensions DisableDelayedExpansion
set "SourceFolder=%LocalAppData%\Packages\FOLDER1\FOLDER2"
set "TargetFolder=C:\hello"
for /F "delims=" %%I in ('dir "%SourceFolder%\*robotknow*" /A-D /B /S 2^>nul') do %SystemRoot%\System32\xcopy.exe "%%~dpI*" "%TargetFolder%\" /C /E /H /K /Q /R /Y >nul
endlocal
The command FOR with option /F starts a separate command process with cmd.exe /C (more precisely %ComSpec% /C) in background to run the command line:
dir "C:\Users\{username}\AppData\Local\Packages\FOLDER1\FOLDER2\*robotknow*" /A-D /B /S 2>nul
DIR outputs to handle STDOUT of background command process
just the names of all files matching the wildcard pattern *robotknow* because of option /A-D (attribute not directory)
even on file having hidden attribute set because of using option /A and not excluding attribute hidden
in bare format because of option /B
with full qualified path because of option /S
found in specified directory or any subdirectory also because of option /S.
It is possible that DIR does not find any file system entry matching these criteria in which case it outputs an error message to handle STDERR. This error message is suppressed by redirecting it to device NUL.
Read the Microsoft article about Using Command Redirection Operators for an explanation of 2>nul. The redirection operator > must be escaped with caret character ^ on FOR command line to be interpreted as literal character when Windows command interpreter processes this command line before executing command FOR which executes the embedded dir command line with using a separate command process started in background.
FOR with option /F captures all lines output to handle STDOUT of started command process and processes them line by line after started cmd.exe terminated itself.
FOR ignores empty lines which do not occur here. FOR ignores by default also all lines starting with a semicolon because of eol=; is the default for end of line character option. But a full qualified file name consisting of full file path, file name and file extension cannot start with ; and so default end of line option can be kept in this case. FOR splits up the lines by default into substrings with using normal space and horizontal tab character as string delimiters and assigns just first space/tab separated substring to specified loop variable. This line splitting behavior is not wanted here because of file path could contain a space character. For that reason option delims= is used to define an empty list of delimiters which disables the line splitting behavior.
So FOR assigns to specified and case-sensitive interpreted loop variable I the full qualified file name found and output by DIR and runs the command XCOPY.
XCOPY is executed with source being the full qualified path of found file referenced with %%~dpI always ending with a backslash concatenated with wildcard * and destination directory being specified target folder C:\hello.
The appended backslash at end of destination directory path makes it 100% clear for XCOPY that the destination is a directory and not a file which prevents the prompt if destination means a directory or a file. \ at end makes also usage of option /I unnecessary and XCOPY creates the entire destination directory structure if necessary.
The other XCOPY options are for really copying all files including files with hidden attribute set in directory containing the file matching the wildcard pattern *robotknow* with all subdirectories including empty subdirectories to destination directory with keeping attributes including read-only attribute.
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
dir /?
echo /?
endlocal /?
set /?
setlocal /?
xcopy /?
See also the list of predefined Windows Environment Variables.

Automating the process of importing project into eclipse workspace using command line interface not working as expected

I have command line argument for importing existing project into eclipse work space. But as soon as I try to execute it using windows batch file eclipse opens and starts loading and closes immediately. Here is the code that I am trying to run.
ECHO on
PUSHD
SET ECLPSE=%cd%
SET WORKSPACE=%~dp0
POPD
SET PATH=%PATH%;%ECLPSE%\bin;
RD /s /q %ECLPSE%\configuration\org.eclipse.equinox.app > Nul
RD /s /q %ECLPSE%\configuration\org.eclipse.osgi > Nul
RD /s /q %ECLPSE%\configuration\org.eclipse.update > Nul
START /B %ECLPSE%\bin\tresos_gui.exe -Dmsg1085=false -data %WORKSPACE% %*
START /B %ECLPSE%\bin\tresos_gui.exe importProject -c C:\Jenkins\jobs
This is the syntax for importing a project into the workspace.
tresos_cmd.bat [<system_property>...] [-data <workspace>]
importProject [-c] <project path>...
Can someone please help me with this. I would really appreciate it. I have even combined last two statements in one line and tried executing it but it is of no use. My main aim is to automate the process of importing project into eclipse workspace so that software can be built using jenkins.
All folder paths containing %ECLPSE% or %WORKSPACE% should be enclosed in double quotes in case of %cd% and/or %~dp0 expand to a folder path with a space character or one of the characters &()[]{}^=;!'+,`~.
I did not really understand what is the goal of the batch file and what tresos_gui.exe is for.
However, here is an improved and commented batch file.
#echo off
setlocal EnableExtensions
rem Path of current directory hold in environment variable CD usually does
rem not end with a backslash (directory separator on Windows). But if the
rem current directory is the root directory of a drive, the directory path
rem ends with a backslash. Assign current directory path to environment
rem variable ECLPSE (strange name) always without a trailing backslash.
if not "%CD:~-1%" == "\" ( set "ECLPSE=%CD%" ) else ( set "ECLPSE=%CD:~0,-1%" )
rem Path of batch file always ends with a backslash, but should be assigned
rem to environment variable WORKSPACE always without a trailing backslash.
set "WORKSPACE=%~dp0"
set "WORKSPACE=%WORKSPACE:~0,-1%"
rem The environment variable PATH can end with a folder path or with a
rem semicolon after last folder path. The subdirectory BIN in current
rem directory should be appended with an additional semicolon only if
rem environment variable PATH does not already end with a semicolon.
if "%PATH:~-1%" == ";" ( set "PATH=%PATH%%ECLPSE%\bin" ) else ( set "PATH=%PATH%;%ECLPSE%\bin" )
rem Command RD does not print any message on success. It prints only an error
rem message to handle STDERR if the directory tree could not be removed.
rd /Q /S "%ECLPSE%\configuration\org.eclipse.equinox.app" 2>nul
rd /Q /S "%ECLPSE%\configuration\org.eclipse.osgi" 2>nul
rd /Q /S "%ECLPSE%\configuration\org.eclipse.update" 2>nul
rem Command START interprets first double quoted string as title for the
rem command process window. Therefore specify as first parameter just ""
rem which is an empty title string.
rem The start of tresos_gui.exe is done for some unknown reason in a separate
rem process in background. Hold execution of batch file until this separate
rem process terminated itself before running tresos_gui.exe a second time
rem to import the project and best wait again until this process terminated.
start "" /WAIT /B "%ECLPSE%\bin\tresos_gui.exe" -Dmsg1085=false -data "%WORKSPACE%" %*
start "" /WAIT /B "%ECLPSE%\bin\tresos_gui.exe" importProject -c C:\Jenkins\jobs
endlocal
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
call /? ... explains %*
cmd /? ... explains with last paragraph on last help page when double quotes are required.
echo /?
endlocal /?
if /?
rd /?
rem /?
setlocal /?
start /?
And read also the Microsoft TechNet article Using command redirection operators for an explanation of 2>nul.

Start Confluent Schema Registry in windows

I have windows environment and my own set of kafka and zookeeper running. To use custom objects, I started to use Avro. But I needed to get the registry started. Downloaded Confluent platform and ran this:
$ ./bin/schema-registry-start ./etc/schema-registry/schema-registry.properties
/c/Confluent/confluent-3.0.0-2.11/confluent-3.0.0/bin/schema-registry-run-class: line 103: C:\Program: No such file or directory
Then I see this on the installation page:
"Confluent does not currently support Windows. Windows users can download and use the zip and tar archives, but will have to run the jar files directly rather than use the wrapper scripts in the bin/ directory."
I was wondering how do I go about starting confluent schema registry in Windows environment ?
Looked at contents of scripts and it is difficult to decipher.
Thanks
Someone has created Windows .bat files as Ewen Cheslack-Postava suggests
https://github.com/renukaradhya/confluentplatform/tree/master/bin/windows
I saved schema-registry-run-class.bat and schema-registry-start.bat into my \confluent\bin\windows directory and then was able to run Schema Registry with
C:\confluent\bin\windows\schema-registry-start.bat C:\confluent\etc\
schema-registry\schema-registry.properties
At the moment Confluent Platform does not ship with any scripts for Windows. However, you can write your own if you're comfortable with running Java applications. The schema-registry-server-start script (and the schema-registry-run-class script it depends on) do things like handle -daemon mode, set Java memory options, setup default log configuration, and more, but ultimately the key piece is that they execute Java with io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain as the main method. You might also find the kafka-run-class.bat from Kafka as a useful base: https://github.com/apache/kafka/blob/trunk/bin/windows/kafka-run-class.bat
The issue is likely the presence of spaces in the JAVA_HOME environment setting for your Windows environment (as evidenced by the error message of "C:\Program" rather than "C:\Program Files..." .
You can determine the EXACT syntax of the final java invocation to launch schema_registry by adding replacing the last "exec" in the schema-registry-run-class script with the word "echo". You'll see the rather convoluted command
/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/java -Xmx512M -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Djava.awt.headless=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dlog4j.configuration=file:/opt/confluent/bin/../etc/schema-registry/log4j.properties -cp :/opt/confluent/bin/../package-schema-registry/target/kafka-schema-registry-package-*-development/share/java/schema-registry/*:/opt/confluent/bin/../share/java/confluent-common/*:/opt/confluent/bin/../share/java/rest-utils/*:/opt/confluent/bin/../share/java/schema-registry/* io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain
That command boils down to "java [core-java-opts] [java-defines] -cp [classpath] io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain
If you replace the "/opt/confluent" references with the actual location of your Confluent install, I suspect you'll have much better luck.
NOTE: I prefer to install Java on windows to a customer location (eg "C:\java8", since many standard scripts will have problems with C:\Program Files deployment location.
I've had success running the confluent tools from cmd.exe using cygwin.
C:\>c:\cygwin64\bin\bash -l /cygdrive/c/confluent/4.0.0/bin/kafka-avro-console-consumer --bootstrap-server <my_server_name>:9092 --topic <my_topic> --property schema.registry.url=http://<my_schema_registry_url>:8081 >> tmp.txt
The code for schema registry run class bat file is :
Save as schema-registry-run-class.bat
#echo off
setlocal EnableExtensions EnableDelayedExpansion
pushd %~dp0..\..
set BASE_DIR=%CD%
popd
for %%i in (%BASE_DIR%/package-schema-registry/target/kafka-schema-registry-package-*-development) do (
call :concat %%i/share/java/schema-registry/*
)
for %%i in (confluent-common, rest-utils, schema-registry) do (
call :concat %BASE_DIR%/share/java/%%i/*
)
rem Log4j settings
IF ["%SCHEMA_REGISTRY_LOG4J_OPTS%"] EQU [""] (
if exist %~dp0../../etc/schema-registry/log4j.properties (
set SCHEMA_REGISTRY_LOG4J_OPTS=-Dlog4j.configuration=file:%~dp0../../etc/schema-registry/log4j.properties
) else (
set SCHEMA_REGISTRY_LOG4J_OPTS=-Dlog4j.configuration=file:%BASE_DIR%/config/log4j.properties
)
)
rem JMX settings
IF ["%SCHEMA_REGISTRY_JMX_OPTS%"] EQU [""] (
set SCHEMA_REGISTRY_JMX_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
)
rem JMX port to use
IF ["%JMX_PORT%"] NEQ [""] (
set SCHEMA_REGISTRY_JMX_OPTS=%SCHEMA_REGISTRY_JMX_OPTS% -Dcom.sun.management.jmxremote.port=%JMX_PORT%
)
rem Which java to use
IF ["%JAVA_HOME%"] EQU [""] (
set JAVA=java
) ELSE (
set JAVA="%JAVA_HOME%/bin/java"
)
rem Memory options
IF ["%SCHEMA_REGISTRY_HEAP_OPTS%"] EQU [""] (
set SCHEMA_REGISTRY_HEAP_OPTS=-Xmx512M
)
rem JVM performance options
IF ["%SCHEMA_REGISTRY_JVM_PERFORMANCE_OPTS%"] EQU [""] (
set SCHEMA_REGISTRY_JVM_PERFORMANCE_OPTS=-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Djava.awt.headless=true
)
set COMMAND=%JAVA% %SCHEMA_REGISTRY_HEAP_OPTS% %SCHEMA_REGISTRY_JVM_PERFORMANCE_OPTS% %SCHEMA_REGISTRY_JMX_OPTS% %SCHEMA_REGISTRY_LOG4J_OPTS% -cp %CLASSPATH% %SCHEMA_REGISTRY_OPTS% %*
%COMMAND%
goto :eof
:concat
IF ["%CLASSPATH%"] EQU [""] (
set CLASSPATH="%1"
) ELSE (
set CLASSPATH=%CLASSPATH%;"%1"
)
The code for schema registry bat file.
Save as schema-registry-start.bat
#echo off
%~dp0schema-registry-run-class.bat io.confluent.kafka.schemaregistry.rest.SchemaRegistryMain %*
The schema registry properties file should look like this:
Save as schema-registry.properties
listeners=http://10.91.31.169:8081
kafkastore.connection.url=10.91.31.169:2181
kafkastore.topic=_schemas
debug=true

Issue with simple quote in bat file

I am trying to execute bat file containing a loop.
When executing a loop, the file execution is aborted.
I modified a little the command to understand what is the error and it seems I cannot put simple quote into the loop.
/f "tokens=1,2 delims==" %%i IN ("version=X.Z.W") do set VERSION=%%j -> success
/f "tokens=1,2 delims==" %%i IN ('version=X.Z.W') do set VERSION=%%j -> failure
It is annoying as version=X.Z.W should be returned by findstr /B /c:"%var%=" ..\..\file.properties
I tested on different desk, and this issue occurs only on my computer.
Do you know if there is any settings to modify?
I have the issue when typing the command directly into a command prompt.
Thanks a lot for your help.
If you are typing the above directly into a command prompt, it will fail because you have used %% instead of %. Windows CMD doesn't read %% as it does processing a batch file.
And the ' as opposed to " are read differently by CMD. ' is read as a command where " is read as a literal string.