| 1. |
Solve : Ping Test Bat? |
|
Answer» Im tring to make a batch file that will run a ping test. Basically, this is what I really have an Im going off memory I wanted to be able to run a batch file that opened a batch file for network testing. Is there a reason to have the batch call another batch? It would seem simpler overall to keep it all within the same file. Currently it pings the loopback address with option 1, pings an entered IP for option 2, and exits for option 3. If you would like to add more functionality to it, it shouldn't be problematic to have it all happen within the construct it is in now. Quote from: Ryuk on January 11, 2012, 10:24:49 AM If its anything other then 3 I wanted it to come back as not a vaild choice. Easy enough. This goes in between the last two lines (notice they are the top and BOTTOM lines in this snippet): Code: [Select]if "%ans%"=="3" (exit) echo Invalid Entry echo. echo Please try again pause goto Menuummm.. No sorry, that was a grammer error on my part. Quote from: Raven19528 on January 08, 2012, 05:43:50 PM What are you trying to accomplish here? You don't have this in any sort of Batch script language. Are you wanting a menu? What do you want the options to do? sadly, it doesnt work. I select each of the three options an it just exits Quote from: Ryuk on January 11, 2012, 11:34:01 AM ummm.. No sorry, that was a grammer error on my part. Quote from: Ryuk on January 21, 2012, 04:10:26 PM sadly, it doesnt work. I select each of the three options an it just exitsMaybe a spelling grammar error. Missing a closing parenthesis.I didnt build this, really I just wondered about how to get user input. Also, what would of been wrong with my code Quote from: Ryuk on January 22, 2012, 10:06:05 AM I didnt build this, really I just wondered about how to get user input. Also, what would of been wrong with my code The code you SAID at the top of the page wouldn't have worked because it isn't properly written, for example "1 Preform a self Ping Test?" would not have been displayed on screen and would have been interpreted as a command, rather than a comment. If you wanted the text to show you need to use the echo command (echo 1 Preform a self Ping Test?) as this tells Ms Dos that the following is not a command, but rather text to be printed on screen. The user input as said by Raven19528 is the "set /p ans=" part where it will set the variable "ans" to whatever the user inputs. Hope this helped.I ment to SAY his code. I can post mine but, I know it wont work an havent done anything with it since. Quote from: Squashman on January 21, 2012, 08:48:05 PM Missing a closing parenthesis. Yes I am, try this on the last few lines: Code: [Select]if "%ans%"=="2" ( set /p ip=IP: ping %ip% pause goto Menu ) if "%ans%"=="3" (exit) goto Menu Notice I missed that final closing parenthesis. Try it now and see what happens.I am able to select know. The issue still remains where it wont allow to do a LOOP back or for entered ip'sYou need to show us the exact code you are using.Im just useing what was posted by Raven |
|