Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: ping not responding in batch  (Read 9461 times)

0 Members and 1 Guest are viewing this topic.

Lemonilla

    Topic Starter


    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
ping not responding in batch
« on: July 07, 2012, 11:17:03 AM »
Sorry to flood the forums (something like 4th thread in a month >.<), but my script seems to stall on a certain command and I'm not sure why. I tried retyping the command into cmd and it worked, but when I try to run the script it stops on the command and just sits there. Any idea's?

Code: [Select]
REM @echo off
@echo on
set c=0
if exist *.1 del /f *.1
setlocal EnableDelayedExpansion

REM set nam=%0
REM FOR /F "tokens=8 delims=\" %%G IN ("%nam%") DO (
REM set nam=%%G
REM )
REM FOR /F "tokens=1 delims=." %%G IN ("!nam!") DO (
REM set nam=%%G
REM )
REM title %nam%
title pingnet

net view | find "\\" >>network.1
echo.



for /f "delims=\\" %%G IN (network.1) DO (
  set /a c+=1
  echo %%G >>net!c!.1
)

set m=%c%
set c=0

:loop.ping
set /a c+=1
set /p y=<net%c%.1
ping %y% -n 1 | find "Min" >>ping%c%.1    <--------------------- Stalls on this command (even when i take out the redirect)
if %c% EQU %m% goto break.rename
goto loop.ping
:break.ping

set c=0

:loop.view
set /a c+=1
type net%c%.1
set /p a=<ping%c%.1
FOR /F "tokens=4 delims==" %%G IN ("%a%") DO (
del /f ping%c%.1
echo %%G >>ping%c%.1
)
if %c% EQU %m% goto break.view
goto loop.view
:break.view

:__
set c=0
set b=0
:1
set /a c+=1
del /f ping%c%.1
set /p a=<net%c%.1
ping %a%| find "Min" >>ping%c%.1
set /p a=<ping%c%.1
FOR /F "tokens=4 delims==" %%G IN ("%a%") DO (
del /f ping%c%.1
echo        %%G >>ping%c%.1
)
:2
set /a b+=1
if %b% EQU %c% goto 3
type net%b%.1
type ping%b%.1
goto 2

:3
set /p 0=< net%c%.1
echo %0%*
type ping%c%.1
if %c% EQU %m% goto __
:4
set /a b+=1
type net%b%.1
type ping%b%.1
if %c% EQU %m% goto __
goto 1

screen output:
Code: [Select]


C:\Users\andude3\Documents\bat>set c=0

C:\Users\andude3\Documents\bat>if exist *.1 del /f *.1

C:\Users\andude3\Documents\bat>setlocal EnableDelayedExpansion

C:\Users\andude3\Documents\bat>REM set nam="C:\Users\andude3\Documents\bat\pingn
etAutoUpdate.bat"

C:\Users\andude3\Documents\bat>REM FOR /F "tokens=8 delims=\" %G IN ("") DO (

C:\Users\andude3\Documents\bat>REM      set nam=%G

C:\Users\andude3\Documents\bat>REM )

C:\Users\andude3\Documents\bat>REM FOR /F "tokens=1 delims=." %G IN ("!nam!") DO
 (

C:\Users\andude3\Documents\bat>REM      set nam=%G

C:\Users\andude3\Documents\bat>REM )

C:\Users\andude3\Documents\bat>REM title

C:\Users\andude3\Documents\bat>title pingnet

C:\Users\andude3\Documents\bat>net view   | find "\\"  1>>network.1

C:\Users\andude3\Documents\bat>echo.


C:\Users\andude3\Documents\bat>for /F "delims=\\" %G IN (network.1) DO (
set /a c+=1
 echo %G   1>>net!c!.1
)

C:\Users\andude3\Documents\bat>(
set /a c+=1
 echo LEMONILLA
      1>>net!c!.1
)

C:\Users\andude3\Documents\bat>(
set /a c+=1
 echo NATHANSCHOOL
      1>>net!c!.1
)

C:\Users\andude3\Documents\bat>set m=2

C:\Users\andude3\Documents\bat>set c=0

C:\Users\andude3\Documents\bat>set /a c+=1

C:\Users\andude3\Documents\bat>set /p y= 0<net1.1

C:\Users\andude3\Documents\bat>ping LEMONILLA
                                    -n 1   | find "Min"  1>>ping1.1
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

Salmon Trout

  • Guest
Re: ping not responding in batch
« Reply #1 on: July 08, 2012, 05:12:59 AM »
I was going to suggest using @echo on but I see you have already tried that.

By the way the second line below is redundant...

REM @echo off
@echo on

Your output seems to be from a different script. The one you posted does not seem to have echo LEMONILLA or echo NATHANSCHOOL in it


Lemonilla

    Topic Starter


    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: ping not responding in batch
« Reply #2 on: July 08, 2012, 09:00:16 PM »
For some reason the window uses wordwrap when I run the scrip, it says echo LEMONILLA on one line when in fact the line is cut into 2 diffrent segments on the screen. The command from the scrip is
Code: [Select]
echo %y% >>net!c!.1
where:
y = LEMONILLA
c = 1

this is also true with ping, which sticks. could this have something to do with the problem?
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: ping not responding in batch
« Reply #3 on: July 11, 2012, 08:19:27 AM »
You code shows a label called break.rename but does it exist?

If so then try this to see if the ping line is executing in an endless fashion.

Code: [Select]
:loop.ping
   set /a c+=1
   set /p y=<net%c%.1
   ping %y% -n 1 | find "Min" >>ping%c%.1    <--------------------- Stalls on this command (even when i take out the redirect)

echo %c% %m%

   if %c% EQU %m% goto break.rename
goto loop.ping

Lemonilla

    Topic Starter


    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: ping not responding in batch
« Reply #4 on: July 11, 2012, 01:43:09 PM »
You code shows a label called break.rename but does it exist?

If so then try this to see if the ping line is executing in an endless fashion.

Code: [Select]
:loop.ping
   set /a c+=1
   set /p y=<net%c%.1
   ping %y% -n 1 | find "Min" >>ping%c%.1    <--------------------- Stalls on this command (even when i take out the redirect)

echo %c% %m%

   if %c% EQU %m% goto break.rename
goto loop.ping

I made the change, and also added the echo %c% you did for testing,  but it never echoed. Thank you for the response.
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

Salmon Trout

  • Guest
Re: ping not responding in batch
« Reply #5 on: July 11, 2012, 02:19:58 PM »
Does %y% expand to a meaningful ip or host name?

Lemonilla

    Topic Starter


    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: ping not responding in batch
« Reply #6 on: July 11, 2012, 02:21:42 PM »
Host name, in the case of the stall 'LEMONILLA' which is the host computer.
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

Salmon Trout

  • Guest
Re: ping not responding in batch
« Reply #7 on: July 11, 2012, 02:22:47 PM »
You are trying to ping localhost using its network name?


foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: ping not responding in batch
« Reply #8 on: July 11, 2012, 04:17:51 PM »
To test this try changing this

ping %y% -n 1 | find "Min" >>ping%c%.1

to this

ping %y% -n 1
pause

and watch it to see what the error message is.

Lemonilla

    Topic Starter


    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: ping not responding in batch
« Reply #9 on: July 11, 2012, 06:39:45 PM »
That seems to be the problem :/ I'm not actually getting an error.
Code: [Select]
C:\Users\andude3\Documents\bat>(
set /a c+=1
 echo NATHANSCHOOL
      1>>net!c!.1
)

C:\Users\andude3\Documents\bat>set m=2

C:\Users\andude3\Documents\bat>set c=0

C:\Users\andude3\Documents\bat>set /a c+=1

C:\Users\andude3\Documents\bat>set /p y= 0<net1.1

C:\Users\andude3\Documents\bat>ping LEMONILLA
                                    -n 1

\\LEMONILLA
\\NATHANSCHOOL

\\

No idea why it's showing the network, or why it is waiting for a prompt.  Usually pause gives a written prompt, but this only response to enter. when you press enter you get :

Code: [Select]
FIND: Parameter format not correct
ad
FIND: Parameter format not correct
aasdfasdf
FIND: Parameter format not correct

This happened even when I deleted the pipe (not just REMed it out).

I guess this is a start, but I still have no idea what it is talking about. Thank you for your help.
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

Salmon Trout

  • Guest
Re: ping not responding in batch
« Reply #10 on: July 11, 2012, 07:53:37 PM »
Have you got a find.bat and/or ping.bat (or .cmd) in the same folder?

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: ping not responding in batch
« Reply #11 on: July 11, 2012, 11:08:24 PM »
Have you got a find.bat and/or ping.bat (or .cmd) in the same folder?

Or anywhere on the path.  Is this batch file you are using called ping?

Squashman



    Specialist
  • Thanked: 134
  • Experience: Experienced
  • OS: Other
Re: ping not responding in batch
« Reply #12 on: July 12, 2012, 05:46:38 AM »
Or anywhere on the path.  Is this batch file you are using called ping?
Have you got a find.bat and/or ping.bat (or .cmd) in the same folder?

That's not the first time someone has made that mistake on this forum.

Salmon Trout

  • Guest
Re: ping not responding in batch
« Reply #13 on: July 12, 2012, 08:03:50 AM »
That's not the first time someone has made that mistake on this forum.

It's the first thing I think of in a situation like this, along with a new variable called PATH .

Lemonilla

    Topic Starter


    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: ping not responding in batch
« Reply #14 on: July 12, 2012, 09:07:02 AM »
Or anywhere on the path.  Is this batch file you are using called ping?
Lol yup. Changed it'd  name and that part works now. Thank a bunch.
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.