|
Answer» hey all,
if i saved a txt file with a ip address in, say 127.0.0.1, and called it a.txt, could i use that data in a dos command??
i.e,
ping >a.txt would it do (ping 127.0.0.1)
if not, is there a way?
any IDEAS???if you have a SINGLE ip address in a file (and it is on the first line), you could do this
set /P MyIP=ping %MyIP%
Grahamhey cheers for that, it's just what i was after.
Having MASTERED that, i now find myself in a slightly different, but yet equally annoying position.
that is to say that i can write said IP address to a text file, "127.0.0.1 >a.txt", but i can't get it write that LAST value on the command line instead (which is what i really require).
i have been thinking along the lines of;
%1 >a.txt
but when run from a prompt "test.bat 127.0.0.1" it doesn't write the IP to the txt file.
any ideas?
cheers again.
any ideas?Running it that way, the IP address would be stored in %1. So if I understand what you want, then your test.bat could CONTAIN: Code: [Select]@echo off echo The passed value is %1 ping %1 Then you could run it test.bat 127.0.0.1
Or if you really do want to write the passed value to a text file, then use the ECHO command like Code: [Select]echo %1 >a.txt
|