中国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 04:04
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,906 / 26
Floor16 sunyao Posted 2006-11-08 00:22
初级用户 Posts 60 Credits 141 From 天津
That is to say, the for statement is to find in the information output by C:\bea\weblogic91\common\bin\wlst.cmd startserver.py, not what I want to find the variable status in startserver.py and get the value of status, right?
Floor17 redtek Posted 2006-11-08 00:32
金牌会员 Posts 1,147 Credits 2,902
for /f %%i in (.......The way you get information: what command or file to execute to get the output.....) do what you want to do with the information obtained by for

So, the for statement is in for /f %%i in (here execute what to get the output information to find)……

This is what Brother electronixtar on the 3rd floor said about the ways to obtain variables from any of the following:
                1. Temporary file
                2. Parameter
                3. Variable
                4. Output redirection

You can get the information (or the variable value you want to obtain) through the for ....(information acquisition approach interface) do ... this method~:)

Since the above several methods can let you get the information (or the variable value you want to obtain),
Then how to obtain the information you want depends on how the information provider (the command or program that provides you with the information) cooperates with your batch processing~:)


Ways to obtain information: (Note: The first, third, and fourth methods to obtain variables)

) The content to be obtained is in the a.txt file, you can treat it as a temporary file (the first type).
  This temporary file can be created with any application and script.

) set /p variable name= assignment statement, get the content of the first line of the a.txt text through <a.txt redirection.
  This is also a way to obtain (exchange) variables.



[ Last edited by redtek on 2006-11-8 at 12:41 AM ]
Floor18 sunyao Posted 2006-11-08 01:09
初级用户 Posts 60 Credits 141 From 天津
Now I use the statement `for /f "skip=34 delims=" %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py') do echo %%i` to find.

`C:\bestway\jcl>echo RUNNING`
RUNNING

`C:\bestway\jcl>echo C:\bestway\jcl>ENDLOCAL`
C:\bestway\jcl>ENDLOCAL

Among them, `RUNNING` is the value I got by using `print status` in `startserver.py`, which should be what I want. But the two results found are `RUNNING` and `C:\bestway\jcl>ENDLOCAL`. Then which one is stored in the variable `%i`? Is it the latter?
Floor19 sunyao Posted 2006-11-08 01:12
初级用户 Posts 60 Credits 141 From 天津
Is it that adding set state= after the for statement assigns the variable %i to state, that is, now state is RUNNING or C:\bestway\jcl>ENDLOCAL
Floor20 redtek Posted 2006-11-08 01:32
金牌会员 Posts 1,147 Credits 2,902
Simulated to build a multi-line data file a.txt (representing the output information containing the string RUNNING that you want to retrieve)


You see that a.txt above has multiple lines, and the last line is g.

Directly obtain the multi-line content of a.txt on the command line and assign it to a variable named "variable".


You see that when the for is executed, it successively assigns the content obtained from a.txt to the variable.
Because it is assigned to the same variable multiple times, so the last sentence: set 变量=g has "erased" the previous assigned values, all replaced by the character g.


The above shows the content of the variable, and the result is the last obtained content: g

So, the valid output you get from the for assignment in sequence is only the last line.
So, for ...skip=skipping lines can solve the content of a specified line when the number of fixed output lines remains unchanged.
So, if == can also solve the situation of accurately matching and finding whether the content you are looking for is in %%i without assignment.

But, it seems that I remember a post where you once wanted to judge whether the Weblogic server was running normally.
If this post is related to the post mentioned above regarding judging whether the Weblogic server starts normally,
then you are taking a very big detour by doing this.
Floor21 sunyao Posted 2006-11-08 01:46
初级用户 Posts 60 Credits 141 From 天津
Yes, the previous post, I used netstat -na | findstr ":80 " to judge whether Weblogic started successfully. But later my superior said to implement the judgment of whether it started in the script. So now I'm trying every way to get the judgment result of the script. There's no way. But I want the result of RUNNING, but now the value of %%i is C:\bestway\jcl>ENDLOCA. Can I delete C:\bestway\jcl>ENDLOCA?
Floor22 redtek Posted 2006-11-08 02:58
金牌会员 Posts 1,147 Credits 2,902
This is to find whether there is the specified string value in the output information obtained through for..()... It can be replaced with the content you specify such as RUN...

(The following code is just the principle. Brother sunyao can rewrite more suitable content specifically: )
(In the code, if is an exact match regardless of case. If fuzzy matching is needed, methods like find or findstr or character replacement can be used)

Floor23 sunyao Posted 2006-11-08 03:17
初级用户 Posts 60 Credits 141 From 天津
for /f "skip=34 delims=" %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py') do (
if /i "%i"=="RUNNING" ( set state="RUNNING" )
)
I'll try if it works
Floor24 sunyao Posted 2006-11-08 04:37
初级用户 Posts 60 Credits 141 From 天津
Tried it, success!!!
Thanks to brother redtek!!!
Let's see if there are any other issues
It's okay, just start making the stop script
Floor25 honhaizh Posted 2006-11-16 20:28
初级用户 Posts 18 Credits 35
Learning
Floor26 hxuan999 Posted 2006-11-23 00:44
中级用户 Posts 161 Credits 337
I was just looking for this
Floor27 electronixtar Posted 2006-11-23 07:20
铂金会员 Posts 2,672 Credits 7,493
People are already discussing WebLogic. That's high-tech.
Prev  1 2
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023