#!/usr/bin/perl # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # bos720 src/bos/usr/bin/cdat/helpers/remote_cmd.pl 1.2 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 2010,2011 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#)91 1.2 src/bos/usr/bin/cdat/helpers/remote_cmd.pl, cdat, bos720 7/14/11 20:46:46 use warnings; use strict; use lib '/usr/lib/cdat/'; use cdat; ###################################################################### # Function: usage # Purpose: Display usage. # Tasks: Print usage and exit. # Input: None # Output: None ###################################################################### sub usage { print(STDERR "Usage: remote_cmd command\n"); exit(1); } ###################################################################### # Function: main # Purpose: Entry point of the remote_cmd command. # Tasks: Execute a command on a remote host using either # telnet or ssh. # Input: command to execute # Output: None ###################################################################### sub main { usage() if (@ARGV != 1); my $user = $ENV{CDAT_USER}; my $host = $ENV{CDAT_HOST}; my $type = $ENV{CDAT_TYPE}; my $cmd = shift @ARGV; if (!defined($user) || !defined($host) || !defined($type)) { printf(STDERR "Bad environment\n"); exit(1); } printf(STDERR "Running remote command \"%s\" on \"%s\" as user \"%s\"\n", $cmd, $host, $user); print cdat::remote_cmd($user, $host, $cmd, $cdat::REMOTE_DONTASKUSER); printf(STDERR "Return code %d\n", $?); exit($?); } main;