There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
process dos commands within txt file


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Code One's Avatar
Junior Member with 5 posts.
 
Join Date: Jan 2004
05-Jan-2004, 12:13 PM #1
process dos commands within txt file
ok i hate to flood the forum with my questions, but i found out that my first question will never get answered, because it is impossible.

so let me change my question:

Does anyone know if it is possible to process a txt file which holds dos commands, from a bat file?

for example
======================
test.txt

del C:\MYDOCU~1\hello.txt
======================
delfile.bat

for sake of limiting this post, the bat file would call for the txt, ?somehow?

see thats my question, how would i call for this txt file that holds dos commands, from my delfile.bat. is that even possible or should i just make another bat file and call that from the main bat file?

and if i shoudl just call another bat file from the main bat file, could someone show me the syntax for that,

thanks

code one
Code One's Avatar
Junior Member with 5 posts.
 
Join Date: Jan 2004
05-Jan-2004, 12:21 PM #2
for example to make my objective more clear, just like when you make a txt file which hold FTP commands and then is processed with a bat file, can I do the same thing only this time with dos commands?


and if so, how?
mole's Avatar
Senior Member with 795 posts.
 
Join Date: Aug 1999
Location: Indian Head, MD "The land of large boxes."
05-Jan-2004, 12:59 PM #3
I'm confused as to what you are asking, do you mean can you create a text file from DOS (command line in NT/2K/XP)?

Yes you can, type:

echo Hi, how are you. > c:\test.txt

Change > to >> to append more lines to the file.

If you mean how do you open a text file, you can do that too:

start c:\test.txt

Will open it in a Windows (assuming you are using Windows DOS or command prompt) application associated with *.txt files.

edit c:\test.txt

Will open the file in the command line text edito.


notepad c:\test.txt

Will open the file in notepad.

...or did I gues totally wrong as to what you are asking?
__________________
mole
coderitr's Avatar
Distinguished Member with 3,080 posts.
 
Join Date: Oct 2003
08-Jan-2004, 09:13 PM #4
The FTP interface allows specifying commands in a text file because the FTP client program is coded with that switch. The program reads the commands from the file and sends them individually to the FTP server. It sounds like what you're trying to do is continue the processing of a batch file using a dynamic text file. What you can do is name the file with a .bat extension and use the CALL statement from within your main batch program. The secondary batch file still must conform to proper syntax but you can put anything you want into it. You must name it .bat or .cmd under WinNT/2K/XP (either will work) or it won't run.
mole's Avatar
Senior Member with 795 posts.
 
Join Date: Aug 1999
Location: Indian Head, MD "The land of large boxes."
09-Jan-2004, 07:10 AM #5
Based upon coderitr's reply, I may have a better idea of what Code One's original post was asking.

It is possible to read the contents of a text file line by line and send the string as a command line parameter(s) to a *.bat or any other file that can work with one for that matter. Your batch would have to be properly constructed to accept parameters and your text file would likewise have to be constructed to provide what is needed:

for /f %a in ('type myfile.txt') do mybatch.bat %a

(use %% for % with "for" inside a batch)

For other than *.bat files, one would similarly parse the output of such a text file line by line for a specific string using the "find" command:

for /f %a in ('type myfile.txt') do echo %a |find /I "mystring" >> {someoutput}

Watch for any wraps in the lines above, they are all intended to be on one line. Also, again, with any command issued from the command prompt, you should check what is returned by issuing /? to get more help. You can even construct your batches to respond to the /? parameter so your will have a "help" section too by echoing instructions followed by the "pause" command.

Good luck, hope that helps.
__________________
mole
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 06:24 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.