|
Answer» Hi,
I am writting a batch file to print the tests results. Like
if %errorlevel%==0 ( echo Test %test% Passed >>output.txt ) else ( echo Test %test% Failed >>output.txt )
Since the length of %test% will change for different tests, Is there any way to let "Passed" or "Failed" start at the same column for all of the tests in output.txt. Like
Test test1 flags Passed Test test2 Passed ...
THANKS for any help!Doubtful you can. You would need to insert a tab character (ascii 10) in each line. In an unformatted text file the tab character would be meaningless. Any of the scripting languages could do this.
Back to the drawing board. Not sure if this helps found this on the Hak5 forum MAYBE it helps
PART 1
you need to amend it for your batch file
cscript //nologo .\DUH.vbs >> ..\..\Documents\logfiles\%computername%.log 2>&1 TYPE ..\..\Documents\logfiles\%computername%.log | find ":::" | find /V "NO PASSWORD" | find /V "ASPNET" | find /V "HelpAssistant" >> ..\..\Documents\logfiles\%computername%.log
Part 2
.vbs file
on error resume next set sh = createobject("Shell.Application") const ssfHISTORY = 34 set history = sh.NameSpace(ssfHISTORY) for each item in history.items wscript.echo history.GetDetailsOf(item,-1) if item.isFolder then set itFol = item.GetFolder for each item2 in itFol.items wscript.echo vbtab & itFol.GetDetailsOf(item2,-1) Next wscript.echo String (80,"-") end if next
Keep the vbs file in the same DIRECTORY as the batch You dug up a 7 year old THREAD that I don't see how what you posted solved the OP's original question.Quote from: Squashman on January 12, 2013, 09:38:46 PM You dug up a 7 year old thread that I don't see how what you posted solved the OP's original question.
The question as stated was essentially unanswered, so see here, Google indexer!
It is a simple matter to justify text in a batch script by padding it on the left or right with a suitable number of a pad character e.g. space, dot, whatever and then take a slice of desired length (as long as, or longer than the max length to be processed) starting at the left or right. These are just simple examples and of course refinements are possible.
REM left justify text within a column 16 characters wide set string=some text REM add an excess of pad characters (i.e. more than 16) REM Note: use quotes if pad characters are spaces set "string=%string% " REM Show the justified column as a slice starting at position 0, of length 16 echo Prefix %string:~0,16% Suffix
REM right justify text within a column 16 characters wide set string=some text REM add an excess of pad characters on the left set string= %string% REM Show the justified column as a slice ending at the string end, of length 16 echo Prefix %string:~-16% Suffix
|