Computing.Net > Forums > Programming > Batch [READ FROM FILE THEN ECHO ]

Batch [READ FROM FILE THEN ECHO ]

Reply to Message Icon

Original Message
Name: JordanVash
Date: July 12, 2007 at 03:05:46 Pacific
Subject: Batch [READ FROM FILE THEN ECHO ]
OS: XP
CPU/Ram: 2gig
Comment:

How would i read text from a certin file, and then echo it back to dos. I know the way u can echo to dos is something like echo bla bla >> Bla.txt.

How would i read stuff from bla.txt, and echo it back into dos prompt?


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: July 12, 2007 at 03:13:19 Pacific
Reply: (edit)

If it's XP, forget DOS.

By 'echo to the prompt' do you mean 'put it on the screen'?

[Rather than in a file?]



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 2
Name: JordanVash
Date: July 12, 2007 at 03:37:50 Pacific
Reply: (edit)

Heh i still call it dos, considering its ms-dos. But anyway. What i meant was..

Say i had a file named boobs.txt and it had jordan is god in the text file

how would i display what is in the text file (jordan is god) into the cmd.exe (ms-dos). Like it reads the text file, and what ever is there it displays on ms-dos


Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: July 12, 2007 at 03:45:14 Pacific
Reply: (edit)

copy boobs.txt con > nul



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 4
Name: FishMonger
Date: July 12, 2007 at 10:24:32 Pacific
Reply: (edit)

Unless I'm misunderstanding your question, this will do what you need.

type boobs.txt


Report Offensive Follow Up For Removal

Response Number 5
Name: JordanVash
Date: July 12, 2007 at 15:13:29 Pacific
Reply: (edit)

did not work, what i want it to do is READ BOOBS.txt. and then whatever is in the text file it displays in cmd.exe


Report Offensive Follow Up For Removal


Response Number 6
Name: Mechanix2Go
Date: July 12, 2007 at 15:43:38 Pacific
Reply: (edit)

"did not work"

Doesn't say much. What might help is to say what it DID; or what it DIDN'T DID.


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 7
Name: FishMonger
Date: July 12, 2007 at 17:36:03 Pacific
Reply: (edit)

You're going to need to come up with a different way of explaining what you want. Based on your current description, both methods that we've given will do what you asked.


Report Offensive Follow Up For Removal

Response Number 8
Name: tonysathre
Date: July 13, 2007 at 11:57:13 Pacific
Reply: (edit)

Like they both said, to display the contents of a text file to STDOUT run this command:

type boobs.txt

Make sure the file you are trying to display is in your current working directory. If it is not, you need to CD to that directory. For example, if boobs.txt is on your Desktop, do this:
Start | Run | cmd and hit Enter | cd desktop | type boobs.txt

@M2,
What is con used for? In the past I've used it to create files like this:
copy con filename.txt
text
...
^z

But what other uses does it have, and what does it actually do?

Thanks,

Tony


"Computer security." — Oxymoron


Report Offensive Follow Up For Removal

Response Number 9
Name: Mechanix2Go
Date: July 14, 2007 at 04:50:32 Pacific
Reply: (edit)

Hi Tony,

con is 'the console'; stdout goes to 'the screen'.

So in your example:

copy con filename.txt

boils dowm to:

copy what I put on the screen to filename.txt
==================
similarly

copy somefile con

means put what's in somefile onto the screen.

For most purposes you don't want the '1 file copied' msg so you:

copy somefile con > nul

which redirects stdout to nul; nul is the 'bit bucket'. What goes in there never comes out. Somewhat like a black hole. But Stephen Hawking is still working on that.

==================================
As to orig post, you can TYPE or COPY without chamgimg dirs.

type x:\some\other\place\somefile

HTH



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 10
Name: tonysathre
Date: July 14, 2007 at 13:59:49 Pacific
Reply: (edit)

"As to orig post, you can TYPE or COPY without chamgimg dirs."

Yes, I know. I just figured he wasn't in the correct directory, and wasn't putting the full path.


"Computer security." — Oxymoron


Report Offensive Follow Up For Removal

Response Number 11
Name: worky
Date: July 31, 2007 at 19:02:21 Pacific
Reply: (edit)

Is this what your looking for? Try out the following.

echo dir > mik.txt
cmd < mik.txt


Report Offensive Follow Up For Removal

Response Number 12
Name: Mechanix2Go
Date: August 1, 2007 at 02:12:58 Pacific
Reply: (edit)

I think he stopped "looking". LOL


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch [READ FROM FILE THEN ECHO ]

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge