Results 1 to 6 of 6

Thread: Batch file append help

  1. #1
    Junior Member
    Join Date
    Oct 2004
    Posts
    1

    Batch file append help

    Hello, I am trying to write a small batch program to get the computer name and IP only. Then copy that info to a server which appends to a text file that exists. so far i have it getting the PC name and IP and putting it into a text file on the PC. But i am lost as how to append all that text to a file on the server. here is what I have so far:

    hostname > c:\temp.txt
    for /f "tokens=2* delims=:" %%a in ('ipconfig ^| find "IP Address"') do set ip=%%a
    set ip=%ip: =%
    set ip=%ip: =%
    echo %ip% >> c:\temp.txt
    copy c:\temp.txt+c:\temp2.txt c:\temp2.txt

    This however does not append to c:\temp2.txt file. If anyone knows where I am going wrong I would love to hear it.

    Thanks

  2. #2
    Advanced Member
    Join Date
    Apr 2001
    Location
    Delaware
    Posts
    900
    Try this:

    hostname > c:\temp.txt

    for /f "tokens=2* delims=:" %%a in ('ipconfig ^| find "IP Address"') do set ip=%%a

    set ip=%ip: =%

    set ip=%ip: =%

    echo %ip% >> c:\temp.txt

    type C:\temp.txt >> C:\temp2.txt
    Fee was a buddhist prodigy...
    Long past the age of maturity...
    Someday he knew it would set him free...
    Like it did for Floyd...
    The Chimpanzee...

  3. #3
    SG Enthusiast FunK's Avatar
    Join Date
    Aug 2000
    Posts
    2,721
    Found the following about the copy command when appending.

    copy myfile1.txt+myfile2.txt = This command would copy the contents in myfile2.txt and combine it with the contents in myfile1.txt.

    Appears to me that your example would actually be writing the appended text back to the original file.

    You code = copy c:\temp.txt+c:\temp2.txt c:\temp2.txt

    Perhaps just using:

    copy c:\temp.txt+c:\temp2.txt - would append to temp.txt ?

    or

    copy c:\temp.txt+c:\temp2.txt >> text3.txt - (if you have to put it in a new file?


    I can't test any of this mind you, I don't have DOS avail att.
    Simply run adaware, spybot, ZoneAlarm, HijackThis, AVG, update windows daily, have a router, don't open e-mail, turn off action scripting, don't use P2P networks, don't violate EULAs, and wear a condom to get Windows secured.

    People say Linux is alot of work!

  4. #4
    Elite Member Norm's Avatar
    Join Date
    Mar 2001
    Posts
    14,133
    Quote Originally Posted by tdog9988
    Try this:

    hostname > c:\temp.txt

    for /f "tokens=2* delims=:" %%a in ('ipconfig ^| find "IP Address"') do set ip=%%a

    set ip=%ip: =%

    set ip=%ip: =%

    echo %ip% >> c:\temp.txt

    type C:\temp.txt >> C:\temp2.txt
    Ths works for me

  5. #5
    Junior Member
    Join Date
    May 2008
    Posts
    1
    Quote Originally Posted by TinyTim View Post
    Try this:

    hostname > c:\temp.txt

    for /f "tokens=2* delims=:" %%a in ('ipconfig ^| find "IP Address"') do set ip=%%a

    set ip=%ip: =%

    set ip=%ip: =%

    echo %ip% >> c:\temp.txt

    type C:\temp.txt >> C:\temp2.txt

    Here's my script code: echo logon %username% %computername% %time% >> \\w03s1721a\tech$\Backups\%username%.log

    This outputs a log file of when the user logs in. I need it to append the date and time each time the user logs in. As of now, the log file is replaced each time a user logs in.

  6. #6
    Junior Member
    Join Date
    Aug 2008
    Posts
    1

    script MS-DOS

    Is anyone who know about a good tutorial on script progrmmming in MS-DOS??
    If yes, if is possiple give the link

Similar Threads

  1. Making a Batch File for a Program?
    By Jin in forum Programming Forum
    Replies: 5
    Last Post: 04-23-08, 07:51 AM
  2. DOS Batch file help
    By Jon in forum Programming Forum
    Replies: 2
    Last Post: 06-04-04, 05:15 AM
  3. How to configure IE file handling
    By GarroteYou in forum General Discussion Board
    Replies: 2
    Last Post: 10-09-03, 05:26 PM
  4. prefetch batch file for XP???
    By jeff8874 in forum Software Forum
    Replies: 1
    Last Post: 02-22-03, 07:33 PM
  5. Security and Encryption FAQ Revision 15 by Doctor Who
    By Marine06 in forum Network Security
    Replies: 1
    Last Post: 02-19-01, 09:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •