WSCP script calls XMLConfig to export WebSphere node configuration to XML file. Tcl inserts timestamp in file name to uniquely identify XML file. Called from Windows shell script.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | @echo off
echo ***************************************************
echo * Export WebSphere configuration on %COMPUTERNAME%
echo ***************************************************
setlocal
set OUTPUTFILE=c:\scripts\websphere\exported_xml\%computername%.xml
call wscp -p c:\scripts\websphere\wscp_properties.txt ^
-f c:\scripts\tcl\exportnode.tcl ^
-- %OUTPUTFILE% ^
%COMPUTERNAME%
endlocal
----------------------------------------------------------------
exportnode.tcl
#
# Export WebSphere configuration
#
######################################
# Set Variables
######################################
set outputfile [lindex $argv 0]
set computername [lindex $argv 1]
puts "\n outputfile = $outputfile \n"
puts "\n computername = $computername \n"
######################################
# Procedures
######################################
######################################
# Proc - check if dir path exists.
######################################
proc check_file {file_name} {
set dirname [file dirname $file_name]
if {[file exists $dirname] == 1} {
puts "\n directory $dirname exists \n"
} else {
error "\n directory $dirname does not exist. Create $dirname before running this script \n"
}
}
######################################################
# Proc - export node
######################################################
proc exportnode {outputfile computername} {
set und _
set filename [file rootname $outputfile]
set ext [file extension $outputfile]
set outputfile_name [file join $filename$und[clock seconds]$ext]
puts "\n exporting WebSphere Configuration on $computername to $outputfile_name \n"
if {[catch [XMLConfig export $outputfile_name] result_var] == 0} {
puts "$result_var"
} else {
error $result_var
}
}
######################################
# Control block"
######################################
#########################################
# Check if output file directories exist.
#########################################
check_file $outputfile
######################################
# Export WebSphere Configuration
######################################
exportnode $outputfile $computername
puts "######################################"
puts "# END."
puts "######################################"
|
Use to automate backups of WebSphere Configuration.
Doesn't work on WAS5. anymore... If I change wscp into wsadmin then errors will result.(invalid command name "XMLConfig")