中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-24 03:11
47,812 topics / 349,917 posts / today 0 new / 48,274 members
DOS批处理 & 脚本技术(批处理室) » Looking for methods for batch processing to accept the return results of scripting languages!
Printable Version  2,900 / 26
Floor1 sunyao Posted 2006-11-07 04:00
初级用户 Posts 60 Credits 141 From 天津
Methods to accept the return results of other scripting languages such as VBS in batch files!
Floor2 sunyao Posted 2006-11-07 04:02
初级用户 Posts 60 Credits 141 From 天津
First, give an example citing the example of user youxi01:

Look at the following code:

@echo off
:: Write a VBS file to find the length of a string
echo temp=wscript.arguments(0) >temp.vbe
echo for i=1 to len(temp) >>temp.vbe
echo if asc(mid(temp,i,1))^<0 then >>temp.vbe
echo strlen=strlen+2 >>temp.vbe
echo else >>temp.vbe
echo strlen=strlen+1 >>temp.vbe
echo end if >>temp.vbe
echo next >>temp.vbe
echo wscript.echo strlen >>temp.vbe
:Start
set /p EN=Please enter a string: (Press Enter directly to exit)=
if not defined EN goto :Over
:: Get the execution result of the VBE file
for /f %%i in ('cscript.exe temp.vbe %EN% //nologo') do echo.&echo The length of the string is: %%i
set EN=
goto :Start
:Over
:: Delete the generated file
del temp.vbe

This sentence is the key:
for /f %%i in ('cscript.exe temp.vbe %EN% //nologo') do ......
Using a for loop to read the VBS return result can also be regarded as a solution for batch processing to receive the return result of a script language. (Of course, in this program, it is not necessary to use for necessarily)
Floor3 electronixtar Posted 2006-11-07 05:13
铂金会员 Posts 2,672 Credits 7,493
1. Temporary files
2. Parameters
3. Variables
4. Output redirection
Floor4 sunyao Posted 2006-11-07 05:28
初级用户 Posts 60 Credits 141 From 天津
Experts, please give a few examples and explain them.
Floor5 youxi01 Posted 2006-11-07 05:39
高级用户 Posts 247 Credits 846 From 湖南==》广东
The meaning of electronixtar is to first use a VBS script or other programs to write the returned results to a file, and then use batch processing to read the file.
Floor6 sunyao Posted 2006-11-07 05:48
初级用户 Posts 60 Credits 141 From 天津
Oh, I understand. The method of using `for /f %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status% //Nologo') do echo %%i` doesn't work.
Floor7 sunyao Posted 2006-11-07 06:45
初级用户 Posts 60 Credits 141 From 天津
electronixtar
Can you please give an example of a VBS script that writes the return result to a file and then uses a batch file to read the file?
Thank you!
Floor8 electronixtar Posted 2006-11-07 08:34
铂金会员 Posts 2,672 Credits 7,493
This ~~ I'll write one
a.vbs

b.bat


Actually, my batch processing is really bad~
Floor9 sunyao Posted 2006-11-07 22:56
初级用户 Posts 60 Credits 141 From 天津
I'm now using
for /f %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status% //Nologo') do echo %%i
I want to get the value of the variable status in the startserver.py file
Why can't I get it out? I'm going crazy
Floor10 zerocq Posted 2006-11-07 23:24
中级用户 Posts 196 Credits 458
Can the batch be divided into two parts? The first part calls vbs to generate parameters, and then let vbs call the second part of the batch with parameters. Is this possible?

What is the use of the part with %status% //Nologo in the parentheses of the line for /f %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status% //Nologo') do echo %%i?
Floor11 zjh7547 Posted 2006-11-07 23:44
新手上路 Posts 2 Credits 4
How to return results when calling an SQL script in batch processing? For example, to get the installation directory of SQL Server, how to get it in batch processing? It's very simple with the SQL command, but I don't know how to pass the obtained string back to DOS.
Floor12 redtek Posted 2006-11-07 23:52
金牌会员 Posts 1,147 Credits 2,902
Originally posted by sunyao at 2006-11-7 22:56:
I am currently using
for /f %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status% //Nologo') do echo %%i
I want to get the value of the variable status in the startserver.py file
Why can't I get it...


) What does C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status% output?

) Does %status% have this variable? What is the content?

) //Nologo is a parameter for wscript.exe: does not display the logo, does not display the logo when executing,
       Is this related to your wlst.cmd startserver.py %status%?
Floor13 sunyao Posted 2006-11-08 00:05
初级用户 Posts 60 Credits 141 From 天津
When I output startserver.py, it shows:
There is no label in the drive
The serial number of the volume is 9c83-6df1
Floor14 sunyao Posted 2006-11-08 00:09
初级用户 Posts 60 Credits 141 From 天津
Is it true that files that can't be listed by dir can't be found?
Floor15 redtek Posted 2006-11-08 00:10
金牌会员 Posts 1,147 Credits 2,902
for /f "delims=" %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py') do echo %%i

Try again, what is output?

As long as the output information of your c:\bea\weblogic91\common\bin\wlst.cmd startserver.py is normal,
and there are no factors in the wlst.cmd code that cause the main batch processing of for /f .... to encounter不可抗力 (such as war, earthquake, ... ~: P).

What text information is output by your C:\bea\weblogic91\common\bin\wlst.cmd startserver.py, and what you retrieve with for is what (except for special cases).

[ Last edited by redtek on 2006-11-8 at 12:12 AM ]
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023