Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
mm@muellermario.de
- Posts: 12
- Joined: 20 Feb 2015 08:24
#1
Post
by mm@muellermario.de » 20 Feb 2015 08:36
Hi everybody,
I wrote a JAVA wich I am calling from a bat.
Code: Select all
java myPackage.MyLitteJAVAPRogramm
The JAVA writes
How can I access the value of
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
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#2
Post
by Squashman » 20 Feb 2015 09:21
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
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#3
Post
by Squashman » 20 Feb 2015 09:29
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
-
mm@muellermario.de
- Posts: 12
- Joined: 20 Feb 2015 08:24
#4
Post
by mm@muellermario.de » 20 Feb 2015 10:51
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
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#5
Post
by foxidrive » 20 Feb 2015 11:49
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.deDid 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.
-
mm@muellermario.de
- Posts: 12
- Joined: 20 Feb 2015 08:24
#7
Post
by mm@muellermario.de » 21 Feb 2015 06:41
hi foxidrive,
I forgot. I uploaded it on google drive. But I need your mailadress. Does dropbox net need a mailadress also?
Regards MM
-
ShadowThief
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
#8
Post
by ShadowThief » 21 Feb 2015 08:02
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.
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#9
Post
by Squashman » 21 Feb 2015 08:39
I do not want the files. I just want to see you execute the program from the command prompt and show the output.
-
ShadowThief
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
#11
Post
by ShadowThief » 21 Feb 2015 10:29
The link can be opened fine. We just needed sample output.
-
mm@muellermario.de
- Posts: 12
- Joined: 20 Feb 2015 08:24
#12
Post
by mm@muellermario.de » 22 Feb 2015 02:51
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
-
mm@muellermario.de
- Posts: 12
- Joined: 20 Feb 2015 08:24
#13
Post
by mm@muellermario.de » 22 Feb 2015 03:05
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.
-
ShadowThief
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
#14
Post
by ShadowThief » 22 Feb 2015 04:05
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?
-
mm@muellermario.de
- Posts: 12
- Joined: 20 Feb 2015 08:24
#15
Post
by mm@muellermario.de » 23 Feb 2015 02:56
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