| 1. |
Solve : set a variable with the output of a command? |
|
Answer» OK, so in bash scripts, it is easy to do whatever you want with programs. if I want the date in the filename, i merely set the filename to be myfile-`date`.txt and the date is added. This is nearly impossible in batch scripting, but i have found out how. This is nearly impossible in batch scripting. What does "nearly" impossible mean? SOMETHING is either possible or it is not. In FACT, including the date in the filename is a trivial task in batch programming. my newest requirement is to have a multi-word command run, such as (for those who are familiar with SVN) svnlook author C:\Repositories\myproject This would output the name of the last person to check in code to myproject I'd like to have a variable with this name in it, such as set AUTHOR= svnlook author C:\Repositories\myproject That, of course, does not work. How can I MAKE it work?! [/quote] In general, we use the FOR command for this kind of thing. If the output of command is a line of text we get the whole line into a variable like this for /f "delims==" %%A in ('command') do set variable=%%A where A is one of a-z or A-Z thanks Dias de VERANO, i hadn't thought of doing it that way before. FB |
|