batch file help, redirect results to text file without losing display of output |
![]() ![]() |
batch file help, redirect results to text file without losing display of output |
May 6 2008, 10:11 PM
Post
#1
|
|
![]() Member ![]() ![]() ![]() Posts: 659 From: Pilipinas OS: Windows XP |
I've tried this as content of ping.bat: ping -t 192.168.1.1 > out.txt It doesn't work. Ctr+C doesn't ask me "Terminate batch job...." like it always does. I have to click x to close the shell. The contents of out.txt is "Terminate batch job...". I find it weird. I've also tried ping 192.168.1.1 > out.txt thinking that -t has something to do with it but no joy. I tried a different command: tracert yahoo.com > out.txt and netstat > out.txt Both works fine. Contents of out.txt is as expected. But, the shell doesn't display the output/results of tracert or netstat. I've ran all batch files from C:\ I want a batch file that pings infinitely 192.168.1.1 and reflects the output to out.txt while still displaying the output on the screen. Thanks guys.... |
|
|
May 7 2008, 04:48 AM
Post
#2
|
|
![]() Trusted Tech Posts: 1,548 From: Steenwijk, The Netherlands OS: Windows XP SP2; Windows Vista Ultimate SP1 |
You where close
I belive that would be CODE ping 192.168.1.1 -t > C:\out.txt That should work Regards, Olrik EDIT: It is normal the shell doesn't show any results because it's writing it directly to "out.txt" This post has been edited by Artellos: May 7 2008, 04:49 AM |
|
|
May 7 2008, 04:53 AM
Post
#3
|
|
![]() Member ![]() ![]() ![]() Posts: 659 From: Pilipinas OS: Windows XP |
Ah...Thanks Olrik. But it didn't work...it just 'hangs'. When I close the shell, out.txt contains Terminate batch job [Y/N]?
|
|
|
May 7 2008, 04:55 AM
Post
#4
|
|
![]() Trusted Tech Posts: 1,548 From: Steenwijk, The Netherlands OS: Windows XP SP2; Windows Vista Ultimate SP1 |
Hmm, odd.
Try going to the Command prompt through the start -> run and in the command box type "ping 192.168.1.1 -t > C:\out.txt" Regards, Olrik |
|
|
May 7 2008, 04:58 AM
Post
#5
|
|
![]() Member ![]() ![]() ![]() Posts: 659 From: Pilipinas OS: Windows XP |
It works perfectly fine....I forgot to mention in my first post that it works if I enter the command directly into the shell. In my experiment, only the netstat and tracert command is "executed properly" from a batch file
|
|
|
May 7 2008, 05:00 AM
Post
#6
|
|
![]() Trusted Tech Posts: 1,548 From: Steenwijk, The Netherlands OS: Windows XP SP2; Windows Vista Ultimate SP1 |
I just tested it myself from the promt aswell and that worked.
Then proceeded to put it in a batch file and when I put the line: "ping 192.168.1.1 > out.txt" in it, run it the shell gave me: "ping 192.168.1.1 1> out.txt" that extra "1" before the ">". I'm going to have a look at this how to go around this. Regards, Olrik |
|
|
May 7 2008, 05:02 AM
Post
#7
|
|
![]() Member ![]() ![]() ![]() Posts: 659 From: Pilipinas OS: Windows XP |
yeeah. mine too. my colleague said it's normal...but i still find it weird
|
|
|
May 7 2008, 05:05 AM
Post
#8
|
|
![]() Trusted Tech Posts: 1,548 From: Steenwijk, The Netherlands OS: Windows XP SP2; Windows Vista Ultimate SP1 |
Hmm, odd.
I just put this line in my batch and it worked: CODE ping -t 192.168.1.1 > out.txt Regards, Olrik This post has been edited by Artellos: May 7 2008, 05:05 AM |
|
|
May 7 2008, 05:09 AM
Post
#9
|
|
![]() Member ![]() ![]() ![]() Posts: 659 From: Pilipinas OS: Windows XP |
Ehhh?! the shell that opens just reads C:\>ping 192.168.2.1 1>out.txt
out.txt contains C:\>ping 192.168.2.1 1>out.txt It still 'hangs' and doesn't recognize Ctrl+C. I need to 'X' it to close the shell |
|
|
May 7 2008, 05:19 AM
Post
#10
|
|
![]() Trusted Tech Posts: 1,548 From: Steenwijk, The Netherlands OS: Windows XP SP2; Windows Vista Ultimate SP1 |
Might sound stupid, but have you tried a reboot?
And I'd say try the following batch: CODE @echo off ping -t 192.168.1.1 > c:\out.txt I would say this should work. Regards, Olrik |
|
|
May 7 2008, 05:21 AM
Post
#11
|
|
![]() Member ![]() ![]() ![]() Posts: 659 From: Pilipinas OS: Windows XP |
hehehe...sorry bro, but i've done those before too...no luck...
i'm on a public PC right now so I'm not as 'free' as I want to be in tinkering with the PC. (the start button and desktop is even removed! but that can't stop me! hehehe) |
|
|
May 7 2008, 05:29 AM
Post
#12
|
|
![]() Trusted Tech Posts: 1,548 From: Steenwijk, The Netherlands OS: Windows XP SP2; Windows Vista Ultimate SP1 |
Sounds a bit as if you're not going to be able to do this.
The batch should work. Doesn't give me any problems. I know that you can disable stuff in the policies to turn some things off in CMD. I wouldn't know anything else from here. Sorry Regards, Olrik |
|
|
May 7 2008, 05:32 AM
Post
#13
|
|
![]() Member ![]() ![]() ![]() Posts: 659 From: Pilipinas OS: Windows XP |
no problem bro. i've got two other colleagues working out this problem of ours on their own machines and i've relayed your suggestions to them. thanks for the time...
|
|
|
![]() ![]() |
Similar Topics
| Topic Title | Replies / Views | Topic Information | |||||
|---|---|---|---|---|---|---|---|
![]() |
2 / 400 | 4th November 2005 - 09:28 PM FGM started - last by Swandog46 |
|||||
![]() |
0 / 288 | 3rd August 2006 - 08:10 AM Preeko started - last by Preeko |
|||||
![]() |
8 / 301 | 13th April 2007 - 06:26 AM stettybet0 started - last by dsenette |
|||||
![]() |
4 / 495 | 16th October 2008 - 05:31 PM pr0n started - last by pr0n |
|||||
|
Time is now: 7th January 2009 - 11:53 PM |
| Advertisements do not imply our endorsement of that product or service. The forum is run by volunteers who donate their time and expertise. We make every attempt to ensure that the help and advice posted is accurate and will not cause harm to your computer. However, we do not guarantee that they are accurate and they are to be used at your own risk. |