China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-31 22:26
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Looking for methods for batch processing to accept the return results of scripting languages! View 2,638 Replies 26
Original Poster Posted 2006-11-07 04:00 ·  IANA 局域网IP(Private-Use)
初级用户
★★
Credits 141
Posts 60
Joined 2006-10-28 05:54
19-year member
UID 68605
Gender Male
From 天津
Status Offline
Methods to accept the return results of other scripting languages such as VBS in batch files!
Floor 2 Posted 2006-11-07 04:02 ·  IANA 局域网IP(Private-Use)
初级用户
★★
Credits 141
Posts 60
Joined 2006-10-28 05:54
19-year member
UID 68605
Gender Male
From 天津
Status Offline
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)
Floor 3 Posted 2006-11-07 05:13 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
1. Temporary files
2. Parameters
3. Variables
4. Output redirection
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +2 2006-11-07 23:02

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 4 Posted 2006-11-07 05:28 ·  IANA 局域网IP(Private-Use)
初级用户
★★
Credits 141
Posts 60
Joined 2006-10-28 05:54
19-year member
UID 68605
Gender Male
From 天津
Status Offline
Experts, please give a few examples and explain them.
Floor 5 Posted 2006-11-07 05:39 ·  中国 广东 清远 联通
高级用户
★★
Credits 846
Posts 247
Joined 2006-10-27 12:03
19-year member
UID 68504
Gender Male
From 湖南==》广东
Status Offline
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.
Floor 6 Posted 2006-11-07 05:48 ·  IANA 局域网IP(Private-Use)
初级用户
★★
Credits 141
Posts 60
Joined 2006-10-28 05:54
19-year member
UID 68605
Gender Male
From 天津
Status Offline
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.
Floor 7 Posted 2006-11-07 06:45 ·  IANA 局域网IP(Private-Use)
初级用户
★★
Credits 141
Posts 60
Joined 2006-10-28 05:54
19-year member
UID 68605
Gender Male
From 天津
Status Offline
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!
Floor 8 Posted 2006-11-07 08:34 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
This ~~ I'll write one
a.vbs

CreateObject("Scripting.FileSystemObject").CreateTextFile("test.txt").write "hello"

b.bat

for /f %a in ("test.txt") do @echo %a


Actually, my batch processing is really bad~
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
redtek +2 2006-11-07 23:17

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 9 Posted 2006-11-07 22:56 ·  IANA 局域网IP(Private-Use)
初级用户
★★
Credits 141
Posts 60
Joined 2006-10-28 05:54
19-year member
UID 68605
Gender Male
From 天津
Status Offline
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
Floor 10 Posted 2006-11-07 23:24 ·  中国 浙江 温州 电信
中级用户
★★
Credits 458
Posts 196
Joined 2006-10-05 12:04
19-year member
UID 64614
Status Offline
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?
Floor 11 Posted 2006-11-07 23:44 ·  中国 广西 北海 电信
新手上路
Credits 4
Posts 2
Joined 2006-09-05 21:58
19-year member
UID 61908
Gender Male
Status Offline
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.
Floor 12 Posted 2006-11-07 23:52 ·  中国 北京 东城区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
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%?
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Floor 13 Posted 2006-11-08 00:05 ·  IANA 局域网IP(Private-Use)
初级用户
★★
Credits 141
Posts 60
Joined 2006-10-28 05:54
19-year member
UID 68605
Gender Male
From 天津
Status Offline
When I output startserver.py, it shows:
There is no label in the drive
The serial number of the volume is 9c83-6df1
Floor 14 Posted 2006-11-08 00:09 ·  IANA 局域网IP(Private-Use)
初级用户
★★
Credits 141
Posts 60
Joined 2006-10-28 05:54
19-year member
UID 68605
Gender Male
From 天津
Status Offline
Is it true that files that can't be listed by dir can't be found?
Floor 15 Posted 2006-11-08 00:10 ·  中国 北京 东城区 联通
金牌会员
★★★★
Credits 2,902
Posts 1,147
Joined 2006-09-21 12:00
19-year member
UID 63324
Gender Male
Status Offline
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 ]
    Redtek,一个永远在网上流浪的人……

_.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
Forum Jump: