help with outputting info from batch file

Joined
11 Mar 2004
Messages
3,454
Ok im running a very simple batch file and i want to admend a text file on a server [(located this way)\\servername\share\text.txt] with everything the batchfile displays after being run admended to the text file.

Any ideas?

btw this is the info that is being run inb the .bat

Code:
Prompt $D 
Prompt $V





Ipconfig /all

ping x.xx.xx.x

tracert  x.xx.xx.x









Pause
 
Last edited:

LeeJend

OSNN Veteran Addict
Joined
25 Jan 2003
Messages
5,291
Crude but:
Redirect the command response to text files then combine them. This works for an unlimited number of commands. There is probably a more ellegant method but I'm tired and a thunder storm is coming in...

Ipconfig /all > \\servername\share\text1.txt
ping x.xx.xx.x > \\servername\share\text2.txt
tracert x.xx.xx.x > \\servername\share\text3.txt

copy \\servername\share\text1.txt + \\servername\share\text2.txt + \\servername\share\text3.txt \\servername\share\text.txt
del \\servername\share\text1.txt
del \\servername\share\text2.txt
del \\servername\share\text3.txt

I wasn't sure if you wanted to keep appending to text.txt for multiple runs. If that's the case then just add text.txt as the first file in the copy list. The copy + command appends all files in the string then saves them to the destination file. You might have to add a /Y to force an over write of text.txt without a prompt but I think it runs without the /Y.

Ipconfig /all > \\servername\share\text1.txt
ping x.xx.xx.x > \\servername\share\text2.txt
tracert x.xx.xx.x > \\servername\share\text3.txt

copy \\servername\share\text.txt + \\servername\share\text1.txt + \\servername\share\text2.txt + \\servername\share\text3.txt \\servername\share\text.txt
del \\servername\share\text1.txt
del \\servername\share\text2.txt
del \\servername\share\text3.txt

You will need to create an empty text.txt to start or you'll get a file not found.
 
Last edited:

fitz

Woah.. I'm still here?
Political Access
Joined
26 Apr 2004
Messages
4,084
Ok im running a very simple batch file and i want to admend a text file on a server [(located this way)\\servername\share\text.txt] with everything the batchfile displays after being run admended to the text file.

Any ideas?
huh? admend? do you mean append?

in which case, why not just run the batch file and redirect to append the output to a text file (ie: test.bat >> \\servername\share\text.txt) or, you could modify the commands in the text file to redirect/appended (ie, in your batch file, run "ping x.x.x.x >> text.txt")

Crude but:
Redirect the command response to text files then combine them. This works for an unlimited number of commands. There is probably a more ellegant method but I'm tired and a thunder storm is coming in...

Ipconfig /all > \\servername\share\text1.txt
no need to copy after wards.. the single ">" will redirect output to a new file (or overwrite an existing file) .. a double ">>" will append to an existing file.
 

LeeJend

OSNN Veteran Addict
Joined
25 Jan 2003
Messages
5,291
:dead: Ooops, I forgot that >> appends.

Ipconfig /all >> \\servername\share\text.txt
ping x.xx.xx.x >> \\servername\share\text.txt
tracert x.xx.xx.x >> \\servername\share\text.txt

Wanna get fancy?

Date >> \\servername\share\text.txt
Time >> \\servername\share\text.txt
Ipconfig /all >> \\servername\share\text.txt
ping x.xx.xx.x >> \\servername\share\text.txt
tracert x.xx.xx.x >> \\servername\share\text.txt
 

LordOfLA

Godlike!
Joined
2 Feb 2004
Messages
7,026
I dont think you can use inc paths in dos. you need to map a network drive to my knowledge. You can do "net use" to do that though.
 

Members online

No members online now.

Latest profile posts

Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.
Terrahertz wrote on Electronic Punk's profile.
Yo fellas!
Electronic Punk wrote on Sazar's profile.
Where are you buddy?
Perris Calderon wrote on Electronic Punk's profile.
Hey EP! All good with me, applying for Microsoft MVP right now, should have done this a while ago.

Notifications don't work, I only found your response by coming back to hunt up some threads, if you want, give me your email address so we can keep in touch easier!
Perris Calderon wrote on Electronic Punk's profile.
EP, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there!

Forum statistics

Threads
61,997
Messages
673,411
Members
5,590
Latest member
AntonioPR