I need to know how I would make a .bat file that would get input (an IP address) and then make a new file (java policy file). I have no clue how to do this....
The following method will work on Windows 2000 and XP: set INPUT=
set /P INPUT=Type input: %=%
echo Your input was: %INPUT%If user hits ENTER without typing anything, the variable (in this case, %input%) keeps it value. So, the first line is to reset its value, so that if nothing is entered the variable will have no value at all, instead of some senseless value.
As you can see, that accepts blank inputs. You can make it to don't accept:
:input
set INPUT=
set /P INPUT=Type input: %=%
if "%INPUT%"=="" goto input
echo Your input was: %INPUT%So, after getting user's input and saving it in a variable, you can use it as you will.
Those samples will fail on DOS and Windows 9x and NT (there are other methods to get user input on such OS's).
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br
OK thanks alot but I still have one more problem.... I need to put to together a new file witht he input...
Like is there a way to insert the input into a text file?
That's the easy part. After getting user's input into a variable, let's say the %input% variable, just do: echo %input%>> file.ext
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br
Sorry to bother you but is there a way to combine two text files? Like now that I have the input in the first text file I need to paste the second half in....
Scratch the last question my problem now is this:
TYPE part1.txt > C:\j2sdk1.4.1_01\bin\myPolicy
:input
set INPUT=
set /P INPUT=Enter the other computers IP address: %=%
if "%INPUT%"=="" goto input
echo IP entered was: %INPUT%
echo %INPUT% >> C:\j2sdk1.4.1_01\bin\myPolicy
TYPE part2.txt >> C:\j2sdk1.4.1_01\bin\myPolicyThe problem is that There is a return between my INPUT and the part2.txt and that screws up teh entire file... How do I fix this?
The output is this:
grant codeBase "http://www.geocities.com/Jman3ooo/-" {
permission java.net.SocketPermission "localhost:1024-", "accept, connect, listen, resolve";
permission java.net.SocketPermission "192.168.0.1
:1024-", "accept, connect, listen, resolve";
};but I want this:
grant codeBase "http://www.geocities.com/Jman3ooo/-" {
permission java.net.SocketPermission "localhost:1024-", "accept, connect, listen, resolve";
permission java.net.SocketPermission "192.168.0.1:1024-", "accept, connect, listen, resolve";
};
Ok I'm confused by the layout on this board (can't tell where it wraps & where it's a real return in file) but this is what I assume... [RETURN] is real hard return in file (or where I think they are...if they're wrong post again with return indicators)...since this board messes it up
part1.txt
grant codeBase[RETURN]
"http://www.geocities.com/Jman3ooo/-"[RETURN]
{[RETURN]
permission[RETURN]
java.net.SocketPermission[RETURN]
"localhost:1024-", "accept,[RETURN]
connect, listen, resolve";[RETURN]
permission[RETURN]
java.net.SocketPermission[RETURN]
"[No-return-at-end-of-file]part2.txt
:1024-", "accept,[RETURN]
connect, listen, resolve";[RETURN]
};[Doesn't-matter-if-there-is-or-not]Ok instead try...
part1.txt
grant codeBase[RETURN]
"http://www.geocities.com/Jman3ooo/-"[RETURN]
{[RETURN]
permission[RETURN]
java.net.SocketPermission[RETURN]
"localhost:1024-", "accept,[RETURN]
connect, listen, resolve";[RETURN]
permission[RETURN]
java.net.SocketPermission[Return-at-end-of-file-this-time]
...end file sooner.part2.txt
connect, listen, resolve";[RETURN]
};[Still-don't-matter]
...start file later..bat file
TYPE part1.txt > C:\j2sdk1.4.1_01\bin\myPolicy[RETURN]
:input[RETURN]
set INPUT=[RETURN]
set /P INPUT=Enter the other computers IP address: %=%[RETURN]
if "%INPUT%"=="" goto input[RETURN]
echo IP entered was: %INPUT%[RETURN]
echo "%INPUT%:1024-", "accept, >> C:\j2sdk1.4.1_01\bin\myPolicy[RETURN]
TYPE part2.txt >> C:\j2sdk1.4.1_01\bin\myPolicy[RETURN]
...modify output line.
| « Appending Text To Multipl... | free more dynamic memory?... » |