943,775 Members | Top Members by Rank

Ad:
Aug 9th, 2008
0

Echo >> problem

Expand Post »
Sorry about the second thread, I forgot to include this on my first one.
Anyways, is it possible for someone to use the "echo %text here% >> %location of file here%" command to save some text to a file in a different folder? I did it, but got a message saying "access denied". I say someone do it with this code:

echo %finalmsg% >> \\BAS-307-15\mikchat\public.txt

But when I do it, for example:

echo %text% >> C:\Documents and Settings\Owner\Desktop\log.txt

It doesn't work! Anyone know whats going on?
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
besktrap is offline Offline
58 posts
since Jul 2008
Sep 3rd, 2008
0

Re: Echo >> problem

Well the problem with using echo %text% >> C:\Documents and Settings\Owner\Desktop\log.txt is that the C:\Documents and Settings\Owner\Desktop\log.txt needs to be in quotes.

I would recommend that you use variables because you can define them at the top of the your code and change their value all throughout the code by simply changing them in one place, e.g.,:

set TEXT="Some Text"
set MYLOG="C:\Documents and Settings\%USERNAME%\Desktop\log.txt"

:: Or your can use this method as well
::
:: set MYLOG="%USERPROFILE%\Desktop\log.txt"
::
:: That is the way that I setup a poorman's alias/macro
:: list for my CMD Sessions. That way each user on the
:: computer will have their own set of aliases/macros.

echo "%text%" >> "%mylog%"

type "%mylog%"

Using that method, all you have to do is make the change in the variable at the top and it is modified all throughout the program.
Reputation Points: 10
Solved Threads: 0
Light Poster
mittelgeek is offline Offline
37 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Legacy and Other Languages Forum Timeline: Batch File...please help!!
Next Thread in Legacy and Other Languages Forum Timeline: Need to send Cntrl +C to an Running Exe using a DOS batch File.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC