Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

batch file help


  • Please log in to reply

#1
TheQuickBrownFox

TheQuickBrownFox

    Member

  • Member
  • PipPipPip
  • 714 posts
Hi guys. Basically I want to perform infinite ping and record the output in a text file. But I've got problems:

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....
  • 0

Advertisements


#2
Artellos

Artellos

    Tech Secretary

  • Global Moderator
  • 3,888 posts
You where close :)

I belive that would be
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"

Edited by Artellos, 07 May 2008 - 04:49 AM.

  • 0

#3
TheQuickBrownFox

TheQuickBrownFox

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 714 posts
Ah...Thanks Olrik. But it didn't work...it just 'hangs'. When I close the shell, out.txt contains Terminate batch job [Y/N]?
  • 0

#4
Artellos

Artellos

    Tech Secretary

  • Global Moderator
  • 3,888 posts
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
  • 0

#5
TheQuickBrownFox

TheQuickBrownFox

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 714 posts
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
  • 0

#6
Artellos

Artellos

    Tech Secretary

  • Global Moderator
  • 3,888 posts
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
  • 0

#7
TheQuickBrownFox

TheQuickBrownFox

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 714 posts
yeeah. mine too. my colleague said it's normal...but i still find it weird
  • 0

#8
Artellos

Artellos

    Tech Secretary

  • Global Moderator
  • 3,888 posts
Hmm, odd.
I just put this line in my batch and it worked:
ping -t 192.168.1.1 > out.txt

Regards,
Olrik

Edited by Artellos, 07 May 2008 - 05:05 AM.

  • 0

#9
TheQuickBrownFox

TheQuickBrownFox

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 714 posts
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
  • 0

#10
Artellos

Artellos

    Tech Secretary

  • Global Moderator
  • 3,888 posts
Might sound stupid, but have you tried a reboot?
And I'd say try the following batch:
@echo off
ping -t 192.168.1.1 > c:\out.txt

I would say this should work. :)

Regards,
Olrik
  • 0

#11
TheQuickBrownFox

TheQuickBrownFox

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 714 posts
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)
  • 0

#12
Artellos

Artellos

    Tech Secretary

  • Global Moderator
  • 3,888 posts
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
  • 0

#13
TheQuickBrownFox

TheQuickBrownFox

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 714 posts
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...:)
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP