Page 1 of 2

Get JAVA system.out.println in bat?

Posted: 20 Feb 2015 08:36
by mm@muellermario.de
Hi everybody,

I wrote a JAVA wich I am calling from a bat.

Code: Select all

java myPackage.MyLitteJAVAPRogramm

The JAVA writes

Code: Select all

system.out.println(myVariable).


How can I access the value of

Code: Select all

myVariable
in my bat?
I can the the value of myVariable in the cmd-Window!!!
But how can I write into a batch-variable?

I am googling for hours; but cannot find a satisfiing hint
Thanky Regards
Mario

Re: Get JAVA system.out.println in bat?

Posted: 20 Feb 2015 09:21
by Squashman
If all your program does is write the variable to STDOUT then you should be able to use this.

Code: Select all

@echo off
FOR /F "delims=" %%G in ('java myPackage.MyLitteJAVAPRogramm') DO set myvariable=%%G

Re: Get JAVA system.out.println in bat?

Posted: 20 Feb 2015 09:29
by Squashman
mm@muellermario.de wrote:I can the the value of myVariable in the cmd-Window!!!

Forgot to ask.
Can you please perform those tasks in a cmd window and then copy and paste all that output from the cmd window to a response here.
thanks

Re: Get JAVA system.out.println in bat?

Posted: 20 Feb 2015 10:51
by mm@muellermario.de
HI Squashman,

thx for the reply. If you want I can send you all -> The jar-files.

It took me a lot of work. I got one batch to decode passwords. The decoded pw is the output in the cmd window and also set to the clipboard.
The user should than copy the decoded PW in an another bat; called decode.bat

This is the bat that makes me problems. It is calling the decoder.java and should receive the decoded pw. This works fine. I can see the decoded pw in the cmd window. But than I want to use ist to logon on an SAP-System; so I have to pass the decoded PW into a variable.

If it works, this would be a very nice tool.

As I have my coding at work, I will do this on monday.


BTW: Is it possible to attach files here in the forum?

regards
Mario

Re: Get JAVA system.out.println in bat?

Posted: 20 Feb 2015 11:49
by foxidrive
Squashman wrote:If all your program does is write the variable to STDOUT then you should be able to use this.

Code: Select all

@echo off
FOR /F "delims=" %%G in ('java myPackage.MyLitteJAVAPRogramm') DO set myvariable=%%G


mm@muellermario.de
Did you try the code above?

Put the word echo before set and try it. What you see on the console?

Add pause as the last line if you are clicking on the batch file.

You can upload the files to dropbox and post the link here - there's no feature to attach them.

Re: Get JAVA system.out.println in bat?

Posted: 21 Feb 2015 06:33
by mm@muellermario.de
hi foxidrive,

not at all. I got the coding at work. at home I only got a mac :| Regards, Mario

Re: Get JAVA system.out.println in bat?

Posted: 21 Feb 2015 06:41
by mm@muellermario.de
hi foxidrive,

I forgot. I uploaded it on google drive. But I need your mailadress. Does dropbox net need a mailadress also?
Regards MM

Re: Get JAVA system.out.println in bat?

Posted: 21 Feb 2015 08:02
by ShadowThief
dropbox.com, not .net

And just put the file in the Public folder and click the Share button. You'll get a link that anybody can use to download the file.

Re: Get JAVA system.out.println in bat?

Posted: 21 Feb 2015 08:39
by Squashman
I do not want the files. I just want to see you execute the program from the command prompt and show the output.

Re: Get JAVA system.out.println in bat?

Posted: 21 Feb 2015 09:29
by mm@muellermario.de
Pls check,

if you can open the link:

https://drive.google.com/folderview?id= ... sp=sharing

Regards, mario

Re: Get JAVA system.out.println in bat?

Posted: 21 Feb 2015 10:29
by ShadowThief
The link can be opened fine. We just needed sample output.

Image

Re: Get JAVA system.out.println in bat?

Posted: 22 Feb 2015 02:51
by mm@muellermario.de
Hi ShadowThief,

sorry I donut understand your question.
The screenshot - as you can see- is decrypting the PW <password>
Now I need to enhance the script, that <password> is passed into a variable.

Thats the problem.


Regards
Mario

Re: Get JAVA system.out.println in bat?

Posted: 22 Feb 2015 03:05
by mm@muellermario.de
This might be confusing.
Concerning the screenshot: I saw that the request its wrong:
I has to be

"Bitte das verschlüsselte Password zum Entschlüsseln eingeben"

In english: pls give the encrypted password for decryption.

Re: Get JAVA system.out.println in bat?

Posted: 22 Feb 2015 04:05
by ShadowThief
I didn't have a question. I was answering a question that was addressed to you.

mm@muellermario.de wrote:This might be confusing.
Concerning the screenshot: I saw that the request its wrong:
I has to be

"Bitte das verschlüsselte Password zum Entschlüsseln eingeben"

In english: pls give the encrypted password for decryption.

I don't see how that's my concern; that's your code, not mine.

Now then, do you need the variable to be the encrypted password or the decrypted password?

Re: Get JAVA system.out.println in bat?

Posted: 23 Feb 2015 02:56
by mm@muellermario.de
Hi ShadowThief,

I am not sure, what is missing now. Could you please see whats wrong in the script?

Code: Select all

@echo off
set CLASSPATH=decoder.jar
FOR /F "delims=" %%G in ('java decode.decoder "dGhpc0lzTXlQVw=="') DO
{ echo set myvariable=%%G
   pause
   echo %G%
   pause

}


The Console-Output is:

Code: Select all

set myvariable=thisIsMyPW
Drücken Sie eine beliebige Taste . . .
ECHO ist ausgeschaltet (OFF).
Drücken Sie eine beliebige Taste . . .


But I cannot see the value of %G%

Thank you much, Regards Mario