#3135 - 2000-05-26 08:41 AM
Capturing output
|
Anonymous
Anonymous
Unregistered
|
Hi all. Has anyone ever seen this problem? I am creating a script that does NSLOOKUP commands on a text file. The script loops through each line in the text file, creates a variable, and dumps it into the command statement to run the NSLOOKUP. When there is no more names, the script exits. All this works fine, however; nothing seems to grab the output the NSLOOKUP command creates (ie. the IP address and FQN). I have tried REDIRECTOUTPUT, which only redirects error/success codes associated with running the command (it's run from a SHELL command). I have also tried SHELLing a ECHO command, but it only echo's the NSLOOKUP command line with the FQN variable. I have run out of ideas. I would appreciate any help/feedback. thanks all. Here's the script so far, still in progress: SETCONSOLE ("HIDE") ; ; /////////////////////////////////////// ; ////////// ////////// ; ////////// IPC.Kix ////////// ; ///////// ///////// ; //////////////////////////////////// ; ; Used to compare the IP address of a domain by NSLOOKUP to the info in the SQL database $SELECTION = MESSAGEBOX ("This program reads domain names from a pre-defined text file called 'wwwname.txt'. While the program runs, you will not see any screen activity. When the program is finished, it will automatically terminate. Hit OK to continue or Cancel to abort.", "NOTICE", 65) IF $SELECTION = "2" GOTO Cancel ENDIF REDIRECTOUTPUT ("d:\docs\junk.txt") BREAK ON Open (1, "d:\docs\wwwname.txt") Open (2, "d:\docs\var1.txt", 5) $N = "d:\docs\var1.txt" ; ; $X = Readline (1) WHILE @ERROR = 0 IF $X = "" GOTO End ENDIF Writeline (2, "$X" + chr (13) + chr (10)) SLEEP 2 CLOSE (2) OPEN (2, "d:\docs\var1.txt") $C = Readline (2) ; Nslookup -[options] [name] [server] (for non-interactive only) CLS DIM $Result $Result = "Nslookup www." + $C + " d1.fipc.net" REDIRECTOUTPUT ("") REDIRECTOUTPUT ("d:\docs\var2.txt") SHELL ("%COMSPEC% CMD/C $Result") ;SHELL ("%COMSPEC% CMD/C ECHO $Result >> d:\docs\var2.bat") this doesn't work Open (3, "d:\docs\var3.txt", 5) WriteLine (3, "$Result" + chr (13) + Chr (10)) SLEEP 1 CLS $X = Readline (1) CLOSE (2) DEL ("d:\docs\var1.txt") OPEN (2, "d:\docs\var1.txt", 5) REDIRECTOUTPUT ("") Loop Close (3) Close (2) Close (1) :END DEL ("d:\docs\var1.txt") $SELECTION = MESSAGEBOX ("Program Finished", "DONE", 64,3) IF $SELECTION = "1" QUIT ENDIF EXIT :Cancel ; user pushed the cancel button, exiting the script before it ran MESSAGEBOX ("Program aborted", "EXIT", 16,3) EXIT
|
|
Top
|
|
|
|
#3136 - 2000-05-26 09:25 AM
Re: Capturing output
|
cj
MM club member
   
Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
|
Hi,Going by your description, here is what I think you are trying to do: code:
; Program to use NSLOOKUP break on cls $path=h:\scripts
"Using $path\wwwname.txt" ? del "$path\output.txt"
$=open(1,"$path\wwwname.txt") if @error<>0 ? color r+/n "Error @error occured: @serror" ? color w/n quit endif
$r=readline(1) while @error=0 $c="www."+$r ? "Performing Lookup on $c" shell "cmd /c nslookup $c >>$path\output.txt 2>nul" $r=readline(1) loop
$=close (1) ? ? ? shell "cmd /c type output.txt" ?
This program takes names from wwwname.txt in $path and does the nslookup on them and outputs all the lookups to $path\output.txt. wwwname.txt is in the format of: ibm.com ozemail.com.au with no blank lines. Here is the output.txt from the above: Server: myserver Address: 1.2.3.4
DNS request timed out. timeout was 2 seconds. Name: www.ibm.com Addresses: 204.146.80.99, 204.146.81.99, 198.133.16.99, 198.133.17.99 Server: myserver Address: 1.2.3.4 Name: www.ozemail.com.au Addresses: 203.108.7.78, 203.108.7.76, 203.108.7.74, 203.108.7.77 Aliases: www.ozemail.com If you like, I can make a post output processor that presents just the first IP address... Can you explain how you want the output formatted? Do you want just an ipaddress etc?
cj
|
|
Top
|
|
|
|
#3137 - 2000-05-26 11:19 AM
Re: Capturing output
|
Anonymous
Anonymous
Unregistered
|
That's it. I needed to grab all the info produced by NSLOOKUP, so I don't need to sort it, just dump it into a text file. I have 13,000 accounts that I have to run this on, obviously this is much faster than manually doing all 13000!!  Thanks for you help.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1607 anonymous users online.
|
|
|