all,
I need some help on how to write a command to the DOS window using the reverse redirection symbol ( < ).
I have searched the internet for hours on trying to get some information on how to do this, but the only i've found is how to redirect OUTPUT to a text file. I need the opposite. I want to redirect the contents of a text file to the command line so I can execute it. Any ideas? Thanks!
DOS reverse redirection
Moderator: DosItHelp
http://ss64.com/nt/for_f.html
You can set different contents of a file as a token and perform a command against it using the for /f command.
You can set different contents of a file as a token and perform a command against it using the for /f command.
Wouldn't the < work in DOS ? Such as
or
This is called INPUT REDIRECTION - sending the contents of a file to a command or a script.
You may also consider using biterscripting if that's an option ( http://www.biterscripting.com ) - here is an example of some commands.
Will catenate or type file C:/myfile.txt
Will execute the script on input from file C:/myfile.txt.
You can also use variables. For example to find out how many lines in file C:/myfile.txt,
or you can use inline command directly as
Code: Select all
type < "C:\myfile.txt"
or
Code: Select all
myscript.bat < "C:\myfile.txt"
This is called INPUT REDIRECTION - sending the contents of a file to a command or a script.
You may also consider using biterscripting if that's an option ( http://www.biterscripting.com ) - here is an example of some commands.
Code: Select all
cat < "C:/myfile.txt"
Will catenate or type file C:/myfile.txt
Code: Select all
script myscript.bat < "C:/myfile.txt"
Will execute the script on input from file C:/myfile.txt.
You can also use variables. For example to find out how many lines in file C:/myfile.txt,
Code: Select all
var str content
cat "C:/myfile.txt" > $content
len $content
or you can use inline command directly as
Code: Select all
len { cat "C:/myfile.txt" }
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Re: DOS reverse redirection
Depends on what you mean. Can you give examples? I would think the for command is going to do what you want if I understand.ajetrumpet wrote:I want to redirect the contents of a text file to the command line so I can execute it. Any ideas? Thanks!