STDOUT to env var

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Apr 28, 2012
1
0
#1
As an example under cmd.exe I used the following hack to get an IP address for a computer:

ping %1 | findstr Pinging | sed "s/^.*\[\(.*\)\].*$/\1/" | set /p IPADDRESS=

what is the easiest equivalent?

I'm currently using:

ping %1 | findstr Pinging | sed "s/^.*\[\(.*\)\].*$/\1/" >%TEMP%\ip
set /p IPA=<%TEMP%\ip
del /q %TEMP%\ip

but would prefer not to use a temporary file.
 
#2
If you used the full TCC, you'd have the variable function @IPADDRESS. Alternately, you can do this:
ping %1 > clip: %+ set IPADDRESS=%@word[2,%@clip[2]]

If %1 is jpsoft.com, this will set IPADDRESS to [141.101.125.120]

NOT TESTED IN TCC/LE!