d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Fix My Script > Paying 100 Fg
Add Reply New Topic New Poll
Member
Posts: 23,518
Joined: Aug 3 2011
Gold: 3,575.00
Mar 20 2018 08:09am
Easy thing/bat file, here is my script:

@ECHO OFF
start cmd.exe /k "tracert google.com > sample.txt
@echo cmd.exe /k "tracert google.com > sample.txt
start cmd.exe /k "ping -n 120 google.com > sample.txt
@echo cmd.exe /k "ping -n 120 google.com > sample.txt

I'm trying to get the ping + trace to save in the same text file but the ping makes the file new and writes over it.
Help me with this simple task and get 100 fg!

Thanks!
Member
Posts: 29,707
Joined: Jun 10 2010
Gold: 7,006.50
Mar 20 2018 08:37am
@echo off&setlocal
set "logfile=sample.txt"
(
tracert google.com
ping -n 120 google.com
)>"%logfile%"
type "%logfile%"
Member
Posts: 2,754
Joined: Nov 26 2007
Gold: 1,339.81
Mar 20 2018 09:39am
just use '>>' instead of '>'
Member
Posts: 23,518
Joined: Aug 3 2011
Gold: 3,575.00
Mar 20 2018 11:17am
Quote (CyberGod @ Mar 20 2018 07:37am)
@echo off&setlocal
set "logfile=sample.txt"
(
tracert google.com
ping -n 120 google.com
)>"%logfile%"
type "%logfile%"


Thanks!

Quote (labatymo @ Mar 20 2018 08:39am)
just use '>>' instead of '>'


Tried that, it didn't work. :/
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll