From: Gareth S B. <bes...@us...> - 2005-04-25 23:19:43
|
Update of /cvsroot/sblim/sfcb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28920 Added Files: wbemcat Log Message: http://sourceforge.net/tracker/index.php?func=detail&aid=1181627&group_id=128809&atid=712784 added wbemcat to sfcb base install existing wbemcat in regressionTests/scripts will be deprecated --- NEW FILE: wbemcat --- #!/usr/bin/perl # $Id: # ============================================================================ # wbemcat # # (C) Copyright IBM Corp. 2005 # # THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE # ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE # CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT. # # You can obtain a current copy of the Common Public License from # http://oss.software.ibm.com/developerworks/opensource/license-cpl.html # # Author: Adrian Schuur, <sc...@de...> # Contributors: Dr. Gareth S. Bestor, <bes...@us...> # Last Updated: April 25, 2005 # Description: # Utility to send CIM-XML request file to a CIMOM and display # the response/results. Default CIMOM is localhost:5988. # If no input file is specified then get XML data from stdin. # ============================================================================ use strict; use Getopt::Long; # Defaults my $port = 5988; my $host = "localhost"; # Usage description sub usage { print "Usage: wbemcat [OPTION]... [FILE]\n"; print "Send FILE containing CIM-XML data to CIMOM and display returned data.\n"; print "If no input FILE specified then read the data from stdin.\n"; print "\nOptions:\n"; print " -h, --host=HOSTNAME\tName of host running the CIMOM. Default=$host\n"; print " -p, --port=PORT\tPort that the CIMOM is listening on. Default=$port\n"; print "\t-?, --help\tDisplay this help and exit\n"; die "\n"; } # Process command line options, if any GetOptions("host|h=s" => \$host, "port|p=i" => \$port, "help|?" => sub{usage}) || usage; my $file = @ARGV[0]; # Read all the XML data from the input file my @xml; if ($file) { open(XMLFILE,"<$file") || die "Cannot open $file: $!"; @xml = (<XMLFILE>); close(XMLFILE) || warn "Cannot close $file: $!"; } else { # If no input file specified then read XML data from stdin @xml = (<STDIN>); } # Calculate size of XML data my $size = 0; foreach $_ (@xml) { $size += length($_); } if ($size == 0) { die "No CIM-XML data"; } # Necessary preamble specifying the length of the CIM-XML data my @preamble = ("POST /cimom HTTP/1.1\n", "Host:\n", "Content-Type: application/xml; charset=\"utf-8\"\n". "Content-Length: ", $size, "\n\n\n"); # Pipe STDOUT to nc command # DEBUG: Comment out this line to see what data gets sent to the CIMOM open(STDOUT, "| nc $host $port") || die "Cannot fork nc command: $!"; # Send preamble and XML data to CIMOM via STDOUT pipe print @preamble; print @xml; close(STDOUT) || warn "Cannot close STDOUT"; |