Tilted Forum Project Discussion Community

Tilted Forum Project Discussion Community (https://thetfp.com/tfp/)
-   Tilted Technology (https://thetfp.com/tfp/tilted-technology/)
-   -   basic/easy question about batch files (https://thetfp.com/tfp/tilted-technology/44782-basic-easy-question-about-batch-files.html)

cowudders14 02-07-2004 07:21 PM

basic/easy question about batch files
 
Ok, I know it's 3AM, but even so, it's only a damn batch file - but it doesn't work!

What am I doing wrong?

blah
ping www.google.co.uk>d:\temp\pinging.log
blah

The file pinging.log is getting created, but there is nothing in it!

I'm using Win 2K.

FYI I'm trying to ping google and my website etc on a fairly frequent basis to keep a log of how good my connection is. Google is just a good site to have a a check that it's my connection, not my website that has gone down, or vice versa.

Cheers all - I know it'll be something stupid, but I thought I'd ask!

digby 02-07-2004 09:39 PM

Quote:

Originally posted by cowudders14

ping www.google.co.uk>d:\temp\pinging.log

If I remember correctly (and that's a big if... this has been a while) you need ">>"

i.e. ping www.domainname.com >> yourfile.txt

Give it a try. If it doesn't work, I'll see if I have any old batch files lying around.

cowudders14 02-08-2004 10:07 AM

Still not working.

Here's the whole batch file. As you can see, I have tried variations on the theme, but none seem to work.


date/t>>d:\temp\pinging.log
time/t>d:\temp\pinging.log
ping www.broadcaster.org.uk >>d:\temp\pinging.log
ping www.daftmoo.co.uk >d:\temp\pinging.log
ping www.google.co.uk>d:\temp\pinging.log
echo line 1 >d:\temp\pinging.log
echo line 2 >d:\temp\pinging.log



Here's the creen output:
D:\Mytemp>date/t1>>d:\temp\pinging.log

D:\Mytemp>time/t1>d:\temp\pinging.log

D:\Mytemp>ping www.broadcaster.org.uk 1>>d:\temp\pinging.log

D:\Mytemp>ping www.daftmoo.co.uk 1>d:\temp\pinging.log

D:\Mytemp>ping www.google.co.uk 1>d:\temp\pinging.log

D:\Mytemp>echo line 1 1>d:\temp\pinging.log

D:\Mytemp>echo line 2 1>d:\temp\pinging.log



The time taken for the screen to go through the lines shows that the ping command is running, but I just can't seem to capture the output. The file created has "line 2" inside it, followed by a blank line, but nothing else.

I'm very confused. Help? :confused:

digby 02-09-2004 09:52 AM

ok, I played with it some, and it worked for me with Win 2k.

Code:

C:\temp>ping 192.168.0.1 >> ping.txt

C:\temp>type ping.txt

Pinging 192.168.0.1 with 32 bytes of data:

Reply from 192.168.0.1: bytes=32 time<10ms TTL=64
Reply from 192.168.0.1: bytes=32 time<10ms TTL=64
Reply from 192.168.0.1: bytes=32 time<10ms TTL=64
Reply from 192.168.0.1: bytes=32 time<10ms TTL=64

Ping statistics for 192.168.0.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum =  0ms, Average =  0ms

As for your echo line # commands, that won't work, because DOS (I believe) doesn't define the lines that way. You are telling it to add the text string "Line 1" to the file.

And one clarification:

">" replaces the text in a file
">>" appends the text

hope this helps.

cowudders14 02-09-2004 01:12 PM

Yep! Thanks! Not sure what I was doing wrong, or why I forgot how to batch program, but that fixed it.
Cheers!

Dilbert1234567 02-10-2004 10:41 PM

as for > vs >>

> rewrites the file to the4 enterd text, where as >> adds the text onto the end of the file


so
Quote:

echo 5> c:\1.txt
echo 5> c:\1.txt
echo 5> c:\1.txt
echo 5> c:\1.txt
echo 5> c:\1.txt
the file 1.txt would contain

Quote:

5
where as

Quote:

echo 5>> c:\1.txt
echo 5>> c:\1.txt
echo 5>> c:\1.txt
echo 5>> c:\1.txt
echo 5>> c:\1.txt
would contain

Quote:

5
5
5
5
5

cowudders14 02-14-2004 09:58 AM

Thanks - I realised the main problem I had beofre was along those lines - it was working, but I wasn't appending. Thus, it was outputting to the file, but as I was leaving a few blank lines at the end (intending to run the file on a regular basis via task scheduler), it was writing the file correctly, the overwriting it with the blank lines. Duh... :)


All times are GMT -8. The time now is 12:54 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62