#!/usr/pkg/bin/perl # safe_script.pl # Copyright 2005-09-06 by Gan Uesli Starling # An example external script for use with the pipe_from_file method # written into these Perl scripts: # gus_xml-rpc_server.pl # gus_xml-rpc_client_tk.pl # See POD at EOF for full description. # 33 lines of code & 190 comment lines. # # Note for Unix: Give this script a 'chmod +x'. Also check the shebang # at top. Shown is for NetBSD. Will be different for Linux, MacOS X, etc! # # Note for Win32: Make sure instead that the extension *.pl is associated # to Perl (either perl.exe or wperl.exe). use strict; use Sys::Hostname; # Get host name of this PC. my $host_name = hostname(); # Return Date Time Group in ISO 8601 approved fashion. sub update_DTG { my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time); my $DTG = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $year + 1900, $mon + 1, $mday, $hour, $min, $sec ); return ("$DTG"); } my $date_time = update_DTG; # Your external Perl scripts should always print a reply. Else the XML-RPC server will # lack for anything to echo back to the client. print "Hello! I am Perl script '$0'.\n"; print "I was executed on $host_name at $date_time.\n"; my $arg_list = "I was given these arguments: "; foreach (@ARGV) { $arg_list .= qq| "$_"| } $arg_list .= "\nBut since I am only a test, I print but otherwise ignore them.\n"; print $arg_list if @ARGV; print "Goodbye!\n"; __END__ =head1 NAME Safe2Pipe test script for XML-RPC server =head1 VERSION Release date = 2005-09-06 =head1 SYNOPSIS perl safe_script.pl "foo bar" =head1 DESCRIPTION A companion example script for the XML-RPC server/client pair B> and B> by same author. Safe to use with their (otherwise possibly dangerous)B>method. Sends one line of text from server to client (or prints to STDOUT if run standalone...as per synopsis). =head1 AUTHOR Gan Uesli Starling > =head1 COPYRIGHT Copyright (c) 2005, Gan Uesli Starling. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SCRIPT CATEGORIES Networking =cut