Dear,
We have modify our searchfiles.kix a little bit. We have modify it
in such a way that we will search for all TNSNAMES.ORA files on your C:\
drive.
After finding such files it will replace them with the specified file
as variable $source. In our example we are using:
$source="\\server\netlogon\tnsnames.ora"
which was marked woth "<+++++" notation.
To make this script effective change
$execute_mode="no"
to
$execute_mode="yes"
Our version:
code:
;
; NT/95 search for specified file(mask)s - Kixtart 3.63, 4.x
;
; (c) scripting@wanadoo.nl 2002
;
; vs 1.00 - program (original: searchfiles.kix)
;
$prgrm_version="1.00"
;
$tmp_directory=ExpandEnvironmentVars("%tmp%")
IF (substr($tmp_directory,len($tmp_directory),1) <> "\")
$tmp_directory=$tmp_directory+"\"
ENDIF
; ---------------------------------------------------------------------------
; user definable part
; ---------------------------------------------------------------------------
$debug_mode="no" ; - yes/no - no = no user output will be viewed
$debug_file=$tmp_directory+"kix-info.log"
$execute_mode="no" ; - yes/no - yes= execute COPY command.
$number_of_dirs=1 ; <- increase value by new dirs to look in
DIM $dirs[$number_of_dirs+1]
$dirs[1]="c:\"
$number_of_files=1 ; <- increase value by new files to check for
DIM $files[$number_of_files+1]
$files[1]="tnsnames.ora"
$source="\\server\netlogon\tnsnames.ora" ; <+++++
; ---------------------------------------------------------------------------
;
; ---------------------------------------------------------------------------
$tmp_file=$tmp_directory+"kixtart.tmp"
;
IF (Exist($debug_file) = 1)
del $debug_file
ENDIF
IF ($debug_mode = "yes")
IF (RedirectOutput($debug_file) <> 0)
ENDIF
ENDIF
? "KIX-SearchFiles "+@kix+" (vs "+$prgrm_version+")"+" "+@date+" "+@time
?
IF (Exist($tmp_file) = 1)
del $tmp_file
ENDIF
$eof="~~~ The command completed succesfully ~~~"
;
$i=1
WHILE ($i <= $number_of_dirs)
$k=1
IF (Substr($dirs[$i],len($dirs[$i]),1) <> "\")
$dirs[$i]=$dirs[$i]+"\"
ENDIF
IF ($debug_mode = "yes")
? "check directory: "+$dirs[$i]
ENDIF
WHILE ($k <= $number_of_files)
$entry=$dirs[$i]+$files[$k]
IF (exist($dirs[$i]) = 1)
SHELL "%comspec% /c dir "+CHR(34)+$entry+CHR(34)+" /a /b /o:n /s >>"+$tmp_file
ENDIF
$k=$k+1
LOOP
$i=$i+1
LOOP
SHELL "%comspec% /c echo "+$eof+">>"+$tmp_file
? "check files: "+$files[1]
$i=2
WHILE ($i <= $number_of_files)
? " "+$files[$i]
$i=$i+1
LOOP
?
$count=0
IF (Exist($tmp_file) = 1)
IF (Open(1,$tmp_file,2) = 0)
$completed="no"
WHILE ($completed <> "yes")
$result=Readline(1)
IF (@error <> 0) or (instr($result,$eof) <> 0)
$completed="yes"
ELSE
IF (exist($result) = 1)
$count=$count+1
GOSUB modify_file_info
ENDIF
ENDIF
LOOP
IF Close(1)
ENDIF
ENDIF
ENDIF
IF (Exist($tmp_file) = 1)
del $tmp_file
ENDIF
?
IF ($count = 0)
? "completed. found no entries."
ELSE
? "completed. found "+$count+" entries."
ENDIF
?
IF (RedirectOutput("") <> 0)
ENDIF
IF ($debug_mode = "yes")
? "Informative SearchFiles: output written to file '"+$debug_file+"'."
ENDIF
EXIT
:modify_file_info
? " replace "+$result
;
IF (Exist($source) = 1)
IF ($execute_mode = "yes")
COPY "$source" "$result" /H
ENDIF
ELSE
? " Warning KIX: file '"+$source+"' not available."
ENDIF
RETURN
An output example is:
code:
KIX-SearchFiles 4.02 (vs 1.00) 2002/04/18 20:15:55
check directory: c:\
check files: tnsnames.ora
replace C:\oracle\tnsnames.ora
Warning KIX: file '\\server\netlogon\tnsnames.ora' not available.
replace C:\WINDOWS\tnsnames.ora
Warning KIX: file '\\server\netlogon\tnsnames.ora' not available.
completed. found 2 entries.
For more information see the related topic to our script searchfiles.kix.
symbol
on our homepage has been linked to this related http://kixtart.org topic.
greetings.