Batch command with slave mode configuration

96 views
Skip to first unread message

Quang Truong

unread,
Sep 16, 2015, 3:39:33 PM9/16/15
to Jenkins Users
Dear all,

I have encountered an issue like this:

- If I setup a slave by downloading and running the jnlp file (no need to install as Window service, just leave the java dialog as connected process). Then I can run this batch command:

setlocal EnableDelayedExpansion
FOR /f "tokens=1 delims=<" %%G IN ('nbtstat -A %VM_IP% ^|FIND "<20>"') DO (
SET Test_Machine_Name=%%G
echo Test_Machine_Name=!Test_Machine_Name!
)

to return a target machine name (from provide IP %VM_IP%)

- But if I run the commandline to setup the slave ( java -jar slave.jar -jnlpUrl http://<JenkinsHostName>:8080/computer/<nodeName>/slave-agent.jnlp -secret <some_long_hex_string>) then I encounter this error: 
'nbtstat' is not recognized as an internal or external command,
operable program or batch file.
I have tried to point the absolute path of the nbtstat

setlocal EnableDelayedExpansion
FOR /f "tokens=1 delims=<" %%G IN ('"C:/Windows/System32/nbtstat.exe -A %VM_IP%" ^|FIND "<20>"') DO (
SET Test_Machine_Name=%%G
echo Test_Machine_Name=!Test_Machine_Name!
)
then got the syntax incorrect.

Please help to guide for solving this issue

Thanks,
Quang

Victor Martinez

unread,
Sep 16, 2015, 4:42:34 PM9/16/15
to Jenkins Users
Hi Quang,

C:/Windows/System32/nbtstat.exe is not windows format. AFAIK it should be backlash instead.

You could try to set your path variable too.

Cheers

Quang Truong

unread,
Sep 17, 2015, 2:15:39 PM9/17/15
to Jenkins Users
Thanks Victor!

I have tried with backlash (actually we can use even Linux syntax here) and use %windir% instead of C:\Windows but still got the syntax error. I don't know how to correct the syntax for this block in FOR command

'"%windir%\System32\nbtstat.exe" -A %VM_IP% ^|FIND "<20>"'

Thanks,
Quang

Quang Truong

unread,
Sep 28, 2015, 8:00:16 AM9/28/15
to Jenkins Users
I have found the root cause: because I changed the way to invoke the slave and the account running the slave connection doesn't have enough permission so that Jenkins doesn't have permission to see nbtstat command.

A workaround is running the slave.jar to call the jnlp from Jenkins master by the java which is defined in Javahome.

Regards,
Quang
Reply all
Reply to author
Forward
0 new messages