Computing.Net > Forums > Disk Operating System > Making a .bat file to get input

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Making a .bat file to get input

Reply to Message Icon

Name: ShadowSilent
Date: March 8, 2003 at 08:02:27 Pacific
OS: 2K
CPU/Ram: 2.0 512
Comment:

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....



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: March 8, 2003 at 12:52:39 Pacific
Reply:

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


0

Response Number 2
Name: ShadowSilent
Date: March 8, 2003 at 19:27:14 Pacific
Reply:

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?


0

Response Number 3
Name: Secret_Doom
Date: March 8, 2003 at 20:10:20 Pacific
Reply:

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


0

Response Number 4
Name: ShadowSilent
Date: March 8, 2003 at 21:11:30 Pacific
Reply:

You saved me!

Thanks a million


0

Response Number 5
Name: ShadowSilent
Date: March 8, 2003 at 21:15:41 Pacific
Reply:

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....


0

Related Posts

See More



Response Number 6
Name: ShadowSilent
Date: March 8, 2003 at 23:35:13 Pacific
Reply:

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\myPolicy

The 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";
};


0

Response Number 7
Name: JSLover
Date: March 10, 2003 at 05:48:05 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Making a .bat file to get input

Making a .bat file to get input NT www.computing.net/answers/dos/making-a-bat-file-to-get-input-nt/12892.html

How to Make a .bat file 2 run programs on usb www.computing.net/answers/dos/how-to-make-a-bat-file-2-run-programs-on-usb/16975.html

I want to make a bat file www.computing.net/answers/dos/i-want-to-make-a-bat-file/2601.html