0

I would want my batch file to execute 3 commands. This is my code:

CALL wsadmin.bat sadmin -conntype %conType% -host %hostName% -port %soapPort% 
wsadmin set jvmProcessDef [$AdminConfig getid /Cell:%cellName%/Node:%nodeName%/Server:%servName%/JavaProcessDef:/JavaVirtualMachine:/] 
wsadmin -lang jacl -f delete.jacl 

When I run this, only the first one gets executed and shows me that it is ignoring the lines after that. I haven't really tried to do any batch scripts before so I don't know if this is possible or is there a way to do this? I have done some readings and research, but it still doesn't work. Any ideas or tips would help.

EDIT:

I tried to chain it like this:

CALL wsadmin.bat sadmin -conntype %conType% -host %hostName% -port %soapPort% && wsadmin set jvmProcessDef [$AdminConfig getid /Cell:%cellName%/Node:%nodeName%/Server:%servName%/JavaProcessDef:/JavaVirtualMachine:/] && wsadmin -lang jacl -f delete.jacl 

And this is the error now:

WASX7209I: Connected to process "server1" on node PHMADGELROSSG1Node01 using SOAP connector;  The type of process is: UnmanagedProcess
WASX7411W: Ignoring the following provided option: [sadmin]
WASX7209I: For help enter, "$Help help"
wsadmin>

Mofi
  • 46,139
  • 17
  • 80
  • 143
Zaveid
  • 21
  • 5
  • 1
    I would assume you would want chain them with `&&` but this question is very unclear. What do you mean by it doesn't work? Doesn't work is a horrible explanation of a problem. – Gerhard Aug 17 '18 at 06:49
  • Sorry about that, I mean it still ignores the commands after the first one. – Zaveid Aug 17 '18 at 06:57
  • 1
    Still unclear, please [edit](https://stackoverflow.com/posts/51889660/edit) the question and show exactly how you run this. – Gerhard Aug 17 '18 at 06:58
  • also, if you run each line on their own, do they execute correctly? – Gerhard Aug 17 '18 at 07:03
  • There. Did I do the chain correctly? I also included the picture of the error that I get. Yes, they execute when they are executed one by one. – Zaveid Aug 17 '18 at 07:07
  • 1
    `&&` lets the following command execute only in case the previous one returned no error (or more precise, an exit code of zero); to unconditionally concatenate multiple commands, use `&`. Anyway, if a command modifies a variable used by a following one, this does not work unless you use [delayed expansion](http://ss64.com/nt/delayedexpansion.html). Nevertheless, I believe you need to use `call` for all lines, because `wsadmin.bat` is a batch-file; without `call`, execution does not return to the calling batch script... – aschipfl Aug 17 '18 at 07:57
  • 1
    Try `call` in front of all three lines _and_ put `echo` commands between the lines so you can be certain whether or not the lines are being reached. – TripeHound Aug 17 '18 at 09:08
  • Thanks for the replies. Let me try those first. – Zaveid Aug 19 '18 at 23:04
  • @aschipfl i tried putting in &, && and CALL but they still don't run. It says that it is ignoring [wsadmin]. Is there another way around this? – Zaveid Aug 19 '18 at 23:23
  • I don't know what `wsadmin` is, but I guess you'll need to check its documentation... you could put `echo` in front of `wsadmin` to verify the variable values; and try using the full path to `wsadmin` also... – aschipfl Aug 20 '18 at 06:32

0 Answers0