Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 587 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
In Windows cmd, how do I prompt for user input and use the result in another command?

#11
There are two possibilities.

1. You forgot to put the `%id%` in the `jstack` call.

jstack %id% > jstack.txt

So the whole correct batch file should be:

@echo off
set /p id=Enter ID:
echo %id%
jstack %id% > jstack.txt

And/Or 2. You did put it in the code (and forgot to tell us in the question) but when you ran the batch file you hit the Enter key instead of typing an ID (say 1234).

What's happening is the result of these two mistakes:
`jstack` is supposed to be called with the id that you supply it.

But in your case (according to the code you supplied in the question) you called it without any variable. You wrote:

jstack > jstack.txt

So when you run `jstack` with no variable it outputs the following:

Terminate batch file Y/N?

Your second mistake is that you pressed Enter instead of giving a value when the program asked you: `Enter ID: `. If you would have put in an ID at this point, say 1234, the `%id%` variable would become that value, in our case 1234. But you did NOT supply a value and instead pressed Enter. When you don't give the variable any value, and if that variable was not set to anything else before, then the variable `%id%` is set to the prompt of the `set` command!! So now `%id%` is set to `Enter ID:` which was echoed on your screen as requested in the batch file BEFORE you called the jstack.

But I suspect you DID have the `jstack %id% > jstack.txt` in your batch file code with the `%id` (and omitted it by mistake from the question), and that you hit enter without typing in an id. The batch program then echoed the id, which is now "Enter ID:", and then ran `jstack Enter ID: > jstack.txt`

Jstack itself echoed the input, encountered a mistake and asked to terminate.
And all this was written into the jstack.txt file.
Reply

#12
set /p choice= "Please Select one of the above options :"
echo '%choice%'

The space after `=` is very important.
Reply

#13
You can try also with [userInput.bat][1] which uses the html input element.

[![enter image description here][2]][2]

This will assign the input to the value jstackId:

call userInput.bat jstackId
echo %jstackId%

This will just print the input value which eventually you can capture with `FOR /F` :

call userInput.bat

[1]:

[To see links please register here]

[2]:

Reply

#14
One other way which might be interesting. You can call a powershell script from where you can do pretty much anything, and send the data bach to cmd or do other stuff with something like this.

set var=myvar;
call "c:\input2.cmd" %var%.

Its kind of more flexible (You can send the data the same way with powershell).

So in your cmd, write this considering the ps script is in `C:`:

PowerShell.exe -ExecutionPolicy unrestricted -Command "& {. C:\Input.ps1}"

And in your input.ps1 script, write this:

$var = Read-Host -Prompt "Your input"
Write-Host "Your var:",$var
#Do stuff with your variable

Reply

#15
**Try this:**

@echo off
set /p "id=Enter ID: "

You can then use `%id%` as a parameter to another batch file like `jstack %id%`.

**For example:**

set /P id=Enter id:
jstack %id% > jstack.txt
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through