Set environment variable = output of exe

G

Guest

I have a simple dos program that returns the IP address
of the host it is run on. I want to setup an environment
variable to be assigned the value of the IP address
returned by this program:

For example...

set ipaddress = | ipclient.exe

I was hoping this would make the environment variable
equal to the IP address of my client but it does not work.

Any suggestion? TIA...
 
W

Wadester

In
I have a simple dos program that returns the IP address
of the host it is run on. I want to setup an environment
variable to be assigned the value of the IP address
returned by this program:

For example...

set ipaddress = | ipclient.exe

I was hoping this would make the environment variable
equal to the IP address of my client but it does not work.

Any suggestion? TIA...

Try this:

for /f "tokens=*" %i in ('ipclient.exe') do set ipaddress=%i

In a batch file, substitute %%i for %i.

Depending on what output ipclient.exe has, you may have to play with the
"tokens=" setting.

ws
 
B

Bill Stewart

I have a simple dos program that returns the IP address of the host it
is run on. I want to setup an environment variable to be assigned the
value of the IP address returned by this program:

For example...

set ipaddress = | ipclient.exe

I was hoping this would make the environment variable equal to the IP
address of my client but it does not work.

You're right -- the above command pipes the result of the command 'set
ipaddress =' to the executable ipclient.exe.

I think you want to do this:

for /f %%a in ('ipclient') do set IPADDRESS=%%a
 
G

guard

I have a simple dos program
that returns the IP address
of the host it is run on. I want to setup an environment
variable to be assigned the value of the IP address
returned by this program:

For example...

set ipaddress = | ipclient.exe

I was hoping this would make the environment variable
equal to the IP address of my client but it does not work.

Any suggestion? TIA...

The Mount/Command ".GetIPAddr" CONSISTENTLY returns
the IP Address under NT/2K/XP/K3 and saves the value
in variable "%#IPAddr%" for further use.

For example:

%.GetIPAddr%
ECHO:IP Address is %#IPAddr%

*******

For a color-keyed example, see
(http://TheSystemGuard.com/MtCmds/GetValue/GetIPAddr.htm)

*******

-tsg
____________________________________________________________
TheSystemGuard.com | BoomingOrFuming.com | MountCommands.com
Free and "Almost Free" Knowledge for Windows System Admins!
 
B

Bill Stewart

guard said:
The Mount/Command ".GetIPAddr" CONSISTENTLY returns the IP Address under
NT/2K/XP/K3 and saves the value in variable "%#IPAddr%" for further use.

Hi John ("guard"),

We all really wish you would listen to our advice instead of stubbornly
ignoring it. Or is it your goal to irritate people?

Please do not crosspost to newsgroups that do not pertain to the subject
matter and platform in question. In case you don't understand what this
means, alt.msdos.batch is not the place for NT-related shell scripting
using cmd.exe. That should be obvious, but evidently it's not.

You are also cross-posting to other newsgroups, but this is considered bad
etiquette. The question was asked in one newsgroup; please answer it in the
same newsgroup without spamming the others.

Also, in case you haven't noticed already, these newsgroups are not the
place to market your "products." All you are doing is annoying the regulars
and getting a bad name for yourself. Please stop insulting us with your
"rise above the rest" nonsense.

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top