From 6c6d831148fcb57e243ed49087f9d7d268626af8 Mon Sep 17 00:00:00 2001 From: Christian Geddes Date: Fri, 20 Apr 2018 11:46:24 -0500 Subject: Create utility script to help automate scp calls to a given system This script will leverage expect to automate scp calls to a given system target. Change-Id: Ica5ebdbe8d3b7674b445ffcd9e7b433ee0ae0359 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/57564 Reviewed-by: Martin Gloff Reviewed-by: Brian E. Bakke Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: Daniel M. Crowell --- src/build/tools/auto_scp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 src/build/tools/auto_scp (limited to 'src/build/tools') diff --git a/src/build/tools/auto_scp b/src/build/tools/auto_scp new file mode 100755 index 000000000..e7f74293e --- /dev/null +++ b/src/build/tools/auto_scp @@ -0,0 +1,50 @@ +#!/usr/bin/expect + +# Description : The purpose of this script is to create a tool which will use +# expect to make scp calls to the FSP easier to do in a script. + +# Take in parameters +set MACHINE [lindex $argv 0]; +set PASSWORD [lindex $argv 1]; +set FILE [lindex $argv 2]; +set OUTDIR [lindex $argv 3]; + +set USER root +if {$argc==5} { +set USER [lindex $argv 4] +} + +# Handle empty parameters +if {$MACHINE==""} { + puts "\nError!! No target machine provided\n" +} + +if {$PASSWORD=="" && $MACHINE!="-h" && $MACHINE!="--help"} { + puts "\nError!! No password provided\n" +} + +if {$FILE=="" && $MACHINE!="-h" && $MACHINE!="--help" } { + puts "\nError!! No filepath to copy provided\n" +} + +if {$OUTDIR=="" && $MACHINE!="-h" && $MACHINE!="--help" } { + puts "\nError!! No output directory on FSP provided\n" +} + +# All parameters are required except USER, if any are missing , or if help flag is set dump +# out some help text to the console +if {$FILE=="" || $MACHINE=="" || $PASSWORD=="" || $OUTDIR=="" || $FILE=="-h" || $FILE=="--help" } { + puts "\nauto_scp \n" + puts "Description: This script will copy a given file onto a given directory on a given fsp." + puts " If no user is provided script will default user to be \"root\"\n" + exit 1; +} + +# Kick off the SCP command +spawn scp -F /gsa/ausgsa/home/h/o/hostboot/fsp.ssh_config $FILE $USER@$MACHINE:$OUTDIR/ + +# This expect part will automatically enter the password passed in as the 2nd param +expect { +password: {send "$PASSWORD\r"; exp_continue} +} + -- cgit v1.2.1