PC Review


Reply
Thread Tools Rate Thread

How to echo the string "command" into a file?

 
 
Aidan Whitehall
Guest
Posts: n/a
 
      9th Jan 2009
This is for a batch file that runs on XP... apologies if this is
strictly a Win2000-only group, but couldn't find a "scripting'" group
under microsoft.public.windowsxp...


I'm using a batch file to echo multiple lines into a file, like so:

echo blah blah >"C:\somefile.txt"
echo blah blah >>"C:\somefile.txt"
echo blah blah >>"C:\somefile.txt"

but the line

echo command blah blah >>"C:\somefile.txt"

isn't being added to somefile.txt. I've tried

echo ^command blah blah >>"C:\somefile.txt"

but still no joy.

Does anyone know how to escape the string "command" such that the line
will be appended to the text file?

Thanks!
 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      9th Jan 2009

"Aidan Whitehall" <(E-Mail Removed)> wrote in message
news:1e51442a-6de4-4664-a200-(E-Mail Removed)...
> This is for a batch file that runs on XP... apologies if this is
> strictly a Win2000-only group, but couldn't find a "scripting'" group
> under microsoft.public.windowsxp...
>
>
> I'm using a batch file to echo multiple lines into a file, like so:
>
> echo blah blah >"C:\somefile.txt"
> echo blah blah >>"C:\somefile.txt"
> echo blah blah >>"C:\somefile.txt"
>
> but the line
>
> echo command blah blah >>"C:\somefile.txt"
>
> isn't being added to somefile.txt. I've tried
>
> echo ^command blah blah >>"C:\somefile.txt"
>
> but still no joy.
>
> Does anyone know how to escape the string "command" such that the line
> will be appended to the text file?
>
> Thanks!


There is nothing special about the word "command". If it does not work for
you then some non-Windows program is intercepting the command. Try it in
Safe Mode!


 
Reply With Quote
 
foxidrive
Guest
Posts: n/a
 
      9th Jan 2009
On Fri, 9 Jan 2009 07:43:51 -0800 (PST), Aidan Whitehall
<(E-Mail Removed)> wrote:

This group is fine for XP etc. It is also on topic in alt.msdos.batch.nt

>I'm using a batch file to echo multiple lines into a file, like so:
>
>echo blah blah >"C:\somefile.txt"
>echo blah blah >>"C:\somefile.txt"
>echo blah blah >>"C:\somefile.txt"
>
>but the line
>
>echo command blah blah >>"C:\somefile.txt"
>
>isn't being added to somefile.txt. I've tried
>
>echo ^command blah blah >>"C:\somefile.txt"
>
>but still no joy.
>
>Does anyone know how to escape the string "command" such that the line
>will be appended to the text file?


try this. The leading redirection stops trailing spaces from being added
in the file also, unless you want them.


>>"C:\somefile.txt" echo/command blah blah



The / is one of many characters that can be used and is the most
compatible, though not always perfect.

Characters like <>|& still need to be escaped with ^ and % is best entered
as %%


 
Reply With Quote
 
Aidan Whitehall
Guest
Posts: n/a
 
      9th Jan 2009
On Jan 9, 4:15*pm, foxidrive <got...@woohoo.invalid> wrote:

> try this. *The leading redirection stops trailing spaces from being added
> in the file also, unless you want them.
>
> >>"C:\somefile.txt" echo/command blah blah

>
> The / is one of many characters that can be used and is the most
> compatible, though not always perfect.
>
> Characters like <>|& still need to be escaped with ^ and % is best entered
> as %%


Thanks all for the info.

Turns out I had (stupidly) missed the % further along the line...
escaping that by doubling it up fixed the problem.

Thanks again for the help... appreciated!
 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      9th Jan 2009

"Aidan Whitehall" <(E-Mail Removed)> wrote in message
news:a00cdd79-1b73-48d9-9e4a-(E-Mail Removed)...
On Jan 9, 4:15 pm, foxidrive <got...@woohoo.invalid> wrote:

> try this. The leading redirection stops trailing spaces from being added
> in the file also, unless you want them.
>
> >>"C:\somefile.txt" echo/command blah blah

>
> The / is one of many characters that can be used and is the most
> compatible, though not always perfect.
>
> Characters like <>|& still need to be escaped with ^ and % is best entered
> as %%


Thanks all for the info.

Turns out I had (stupidly) missed the % further along the line...
escaping that by doubling it up fixed the problem.

Thanks again for the help... appreciated!
=======

Strange - I can't see any %, missing or otherwise, in the example you gave
us . . .

echo command blah blah >>"C:\somefile.txt"


 
Reply With Quote
 
billious
Guest
Posts: n/a
 
      10th Jan 2009
Aidan Whitehall wrote:
> On Jan 9, 4:15 pm, foxidrive <got...@woohoo.invalid> wrote:
>
>> try this. The leading redirection stops trailing spaces from being
>> added in the file also, unless you want them.
>>
>>>> "C:\somefile.txt" echo/command blah blah

>>
>> The / is one of many characters that can be used and is the most
>> compatible, though not always perfect.
>>
>> Characters like <>|& still need to be escaped with ^ and % is best
>> entered as %%

>
> Thanks all for the info.
>
> Turns out I had (stupidly) missed the % further along the line...
> escaping that by doubling it up fixed the problem.
>
> Thanks again for the help... appreciated!


....and perhaps you should try alt.msdos.batch.nt for batch questions and
tips - it probably has twenty times the traffic you'll find here!

(but please - the code-frag that you're using, OK?)


 
Reply With Quote
 
Timo Salmi
Guest
Posts: n/a
 
      11th Jan 2009
Aidan Whitehall <(E-Mail Removed)> wrote:
> but the line
> echo command blah blah >>"C:\somefile.txt"
> isn't being added to somefile.txt. I've tried


You might wish to brush up on poison characters and escape characters in
cmd scripting. E.g.
http://www.netikka.net/tsneti/info/tscmd047.htm
http://www.netikka.net/tsneti/info/tscmd012.htm#poison
http://lipas.uwasa.fi/~ts/http/http2.html#cmdscript

All the best, Timo

--
Prof. Timo Salmi private.php?do=newpm&u= ftp & http://garbo.uwasa.fi/
Hpage: http://www.uwasa.fi/laskentatoimi/en...nel/salmitimo/
Department of Accounting and Finance, University of Vaasa, Finland
Useful CMD script tricks http://www.netikka.net/tsneti/info/tscmd.htm
 
Reply With Quote
 
Aidan Whitehall
Guest
Posts: n/a
 
      12th Jan 2009
On Jan 9, 7:09*pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:

> Strange - I can't see any %, missing or otherwise, in the example you gave
> us . . .
>
> echo command blah blah * * * * >>"C:\somefile.txt"


Yeah, I usually tidy up problematic code when posting as I've found
that great swathes of code can both obfuscate the cause of the problem
and deter others from assisting.

In this instance I also managed to tidy up the cause of the problem...
my bad!
 
Reply With Quote
 
Aidan Whitehall
Guest
Posts: n/a
 
      12th Jan 2009
On Jan 10, 2:45*am, "billious" <billious_1...@hotmail.com> wrote:

> ...and perhaps you should try alt.msdos.batch.nt for batch questions and
> tips - it probably has twenty times the traffic you'll find here!


I'll bear that group in mind... thanks.


> (but please - the code-frag that you're using, OK?)


Does that mean prefix lines of code with dashes?
 
Reply With Quote
 
Aidan Whitehall
Guest
Posts: n/a
 
      12th Jan 2009
On Jan 11, 7:11*pm, Timo Salmi <t...@uwasa.fi> wrote:

> You might wish to brush up on poison characters and escape characters in
> cmd scripting. E.g.
> *http://www.netikka.net/tsneti/info/tscmd047.htm
> *http://www.netikka.net/tsneti/info/tscmd012.htm#poison
> *http://lipas.uwasa.fi/~ts/http/http2.html#cmdscript


Will take a look... thanks Timo.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting "uppercase" string data to "lower case" in CSV file akarui.tomodachi@gmail.com Microsoft Excel Misc 2 12th Aug 2008 08:36 PM
text string: "91E10" in csv file auto converts to: "9.10E+11" Alex@2256036124.com Microsoft Excel Misc 2 12th Aug 2008 03:13 PM
Echo multiple messages separated by new line thorugh "echo" command Vijay Jain Windows XP General 1 12th Dec 2006 09:11 PM
Help: SyncToy 1.4 in "Echo" mode doesn't auto-select/Copy "New" fi =?Utf-8?B?SmVyZW15TW9za293aXR6KE1WUCk=?= Windows XP Photos 0 24th Nov 2006 08:21 PM
after a ftp put command it just says "200 PORT command successful." and hangs forever. What could be wrong? when i test the ftp server using IE in "passive" mode it works fine. but ftp at command line hangs on "200 PORT comma Daniel Microsoft Windows 2000 Networking 1 29th Apr 2006 02:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:25 PM.