Forum Articles
  Welcome back Join CF
You are here You are here: Home | Forum | I need help with a batch file

You are currently viewing our boards as a guest which gives you limited access to view most of the discussions, articles and other free features. By joining our Virgin Media community you will have full access to all discussions, be able to view and post threads, communicate privately with other members (PM), respond to polls, upload your own images/photos, and access many other special features. Registration is fast, simple and absolutely free so please join our community today.


Welcome to Cable Forum
Go Back   Cable Forum > Computers & IT > General IT Discussion
Register FAQ Community Calendar

I need help with a batch file
Reply
 
Thread Tools
Old 08-09-2009, 11:52   #1
funkyCable
THE FUNKIEST ON THE BOARD
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
I need help with a batch file

Hi,

I'm trying to create a batch file to run a tracert and out the results to a file to see if its going through a different route.

How do I do it and can I loop it say 100 times?

I know this may sound dodgy but I'm trying to prove to our companys IT suppliers that we are using two different proxies and one is being used random and blocking our users from accessing our site.

if we use a user friendly url it causes problems but if you use the server name directly then it does not cause a problem.

please any help much appreciate.
funkyCable is offline   Reply With Quote
Advertisement
Old 08-09-2009, 11:58   #2
Kymmy
Inactive
 
Join Date: Dec 2007
Posts: 18,385
Kymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny stars
Kymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny stars
Re: I need help with a batch file

To output tracert to a file it's just as simple as adding > XXXX.txt to the end, if you want it to append to a file it's >> XXXX.txt

For example

Code:
tracert bbc.co.uk > trace.txt
will give you the traceroute in a file called trace.txt

If you repeated it with
Code:
tracert bbc.co.uk >> trace.txt
it would add a 2nd tracert to the same file.

Just loop that in a batch file 100 time (there's a few different methods) and you should have you file.
Kymmy is offline   Reply With Quote
Old 08-09-2009, 11:58   #3
Graham M
-
 
Graham M's Avatar
 
Join Date: Jul 2003
Location: Poole, Dorset
Age: 40
Services: FreeSat+ Tivo V-Box VM 60MBit
Posts: 13,365
Graham M has a pair of shiny starsGraham M has a pair of shiny stars
Graham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny starsGraham M has a pair of shiny stars
Send a message via MSN to Graham M Send a message via Yahoo to Graham M
Re: I need help with a batch file

A tracert will not show 2 different web proxies though?
Graham M is offline   Reply With Quote
Old 08-09-2009, 12:06   #4
funkyCable
THE FUNKIEST ON THE BOARD
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
Re: I need help with a batch file

yeah but maybe its a firewall somewhere and it can give me some IP addresses I could chekc with the support team.

Thanks Kymmy how do I loop that.

---------- Post added at 12:06 ---------- Previous post was at 12:01 ----------

Graham what do you suggest I try to trace the connection my pc to my server?
funkyCable is offline   Reply With Quote
Old 08-09-2009, 12:12   #5
Kymmy
Inactive
 
Join Date: Dec 2007
Posts: 18,385
Kymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny stars
Kymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny stars
Re: I need help with a batch file

Set a variable, increment it by one, check within a loop if it gets to 100 if so then point past the loop

Not done batch files for years but something like

Code:
@echo off
set /a var=%1
:LOOP
if %var% gtr %100 goto :END
tracert bbc.co.uk >> trace.txt
set /a var+=1
goto LOOP
:END
Grabbed the code from a quick search as I've not done batch files for a long, long, long, long time (since dos 5 ) but it's basicallya simple

set VAR to 1, loop start, if var is greater than 100 then goto end, tracert to file, add 1 to VAR, goto loop, end
Kymmy is offline   Reply With Quote
Old 08-09-2009, 12:31   #6
funkyCable
THE FUNKIEST ON THE BOARD
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
Re: I need help with a batch file

hmm that code seems logical but it does not seem to be doing anything. If I run just the tracert by itself it writes the results to the file but if I place that in the loop it does not create the file and does not append anything to it.

Any ideas?

I really need to get some good reference on batch files. They can be really useful.

---------- Post added at 12:31 ---------- Previous post was at 12:31 ----------

how can I append the VAR value to the file as well ?
funkyCable is offline   Reply With Quote
Old 08-09-2009, 12:54   #7
Kymmy
Inactive
 
Join Date: Dec 2007
Posts: 18,385
Kymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny stars
Kymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny starsKymmy has a pair of shiny stars
Re: I need help with a batch file

replace trace.txt with %%var (each % represents a digit)

---------- Post added at 12:54 ---------- Previous post was at 12:50 ----------

as I said though it has been a long, long, long time since I did a batch file

It seems to have a problem with the IF statement, I'm sure that one of the usual programmers will be round shortly
Kymmy is offline   Reply With Quote
Old 08-09-2009, 13:08   #8
Dai
Inactive
 
Join Date: Dec 2006
Location: Lincoln UK
Age: 76
Services: 50Mb, TV & Phone
Posts: 3,673
Dai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronze
Dai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronzeDai is cast in bronze
Send a message via MSN to Dai
Re: I need help with a batch file

Since the loop appends to a file it expects to find it existing. Try creating an empty file with that name before running the bat.
Dai is offline   Reply With Quote
Old 08-09-2009, 13:19   #9
funkyCable
THE FUNKIEST ON THE BOARD
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
Re: I need help with a batch file

Hi David,

I tried that and still no luck. This is my batch file. Does it not need some sort of pause to process it?

Code:
@echo off
set /a var=%1
:LOOP
if %var% gtr %100 goto :END
tracert xxxxxxx.xxx >> d:/traceresults.txt
set /a var+=1
goto LOOP
:END
funkyCable is offline   Reply With Quote
Old 08-09-2009, 13:40   #10
Druchii
cf.mega poster
 
Druchii's Avatar
 
Join Date: Mar 2006
Location: Oslo, Norway.
Age: 36
Services: Canal Digital: 50/10
Posts: 7,577
Druchii has a nice shiny star
Druchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny starDruchii has a nice shiny star
Re: I need help with a batch file

With vbscript and batch:

vbscript:
Code:
dim i
dim wsh
for i = 0 to 99
Set Wsh = WScript.CreateObject("WScript.Shell")
Wsh.Run "traceit.bat", 1
WScript.Sleep 15000
next
And now the batch, call it "traceit.bat":
Code:
tracert bbc.co.uk >> trace.txt
Place both in same folder. There is a 15sec delay between each tracert t give it time to complete.

---------- Post added at 14:40 ---------- Previous post was at 14:36 ----------

Want to make it silent as well? Just tells you when it's done...:

VBscript:
Code:
dim i
dim wsh
for i = 0 to 99
Set Wsh = WScript.CreateObject("WScript.Shell")
Wsh.Run "traceit.bat", 0
WScript.Sleep 15000
next
msgbox "Completed Tracerts!"
Druchii is offline   Reply With Quote
Old 08-09-2009, 13:58   #11
funkyCable
THE FUNKIEST ON THE BOARD
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
Re: I need help with a batch file

Am I'm right in thinking I need to run the vbScript? how do I create the vbscript file?

Sorry I'm more of a pl/sql coder.
funkyCable is offline   Reply With Quote
Old 08-09-2009, 14:02   #12
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Re: I need help with a batch file

create the VBScript file using notepad (or similar) and save it as '<filename>.vbs'.

You should then just be able to double-click it to run it.
Raistlin is offline   Reply With Quote
Old 08-09-2009, 15:14   #13
funkyCable
THE FUNKIEST ON THE BOARD
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
Re: I need help with a batch file

thanks I've run that and counted the entrys and they is no way there is 100 entrys in the txt file.

Any ideas why there would be some missing?
funkyCable is offline   Reply With Quote
Old 08-09-2009, 16:12   #14
idi banashapan
step on my trip
 
idi banashapan's Avatar
 
Join Date: Jul 2003
Posts: 3,757
idi banashapan has a nice shiny star
idi banashapan has a nice shiny staridi banashapan has a nice shiny staridi banashapan has a nice shiny staridi banashapan has a nice shiny staridi banashapan has a nice shiny staridi banashapan has a nice shiny staridi banashapan has a nice shiny staridi banashapan has a nice shiny staridi banashapan has a nice shiny staridi banashapan has a nice shiny staridi banashapan has a nice shiny staridi banashapan has a nice shiny staridi banashapan has a nice shiny star
Re: I need help with a batch file

did you give it enough time tio run fully?
__________________
“Most people don’t listen to understand. They listen to reply. Be different.”

- Jefferson Fisher
idi banashapan is offline   Reply With Quote
Old 08-09-2009, 16:16   #15
funkyCable
THE FUNKIEST ON THE BOARD
 
Join Date: Aug 2005
Location: Canvey Island, Essex
Services: SERVICES FROM 26/08/05 TV XL services 2MB BROADBRAND UNLIMITED TALK PACKAGE V+ Service (Since 18
Posts: 1,195
funkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nicefunkyCable is just really nice
Re: I need help with a batch file

I left it with the 15sec delay but I just counted 12 entries. I did take around 20mins to run before I got the msgbox saying it was complete.
funkyCable is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:15.


Server: osmium.zmnt.uk
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum