-
Notifications
You must be signed in to change notification settings - Fork 154
/
transfer_script.sh
72 lines (58 loc) · 2.07 KB
/
transfer_script.sh
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
#!/bin/bash
# Script Name : transfer_script.sh
# Author : Craig Richards
# Created : 18-July-2012
# Last Modified :
# Version : 1.0
# Modifications :
# Description : This will send a given script to a certain server once prompted, if it can't find the script it searches for scripts with a similar name
#################################
# Start of procedures/functions #
#################################
funct_check_params()
{
if [ ${NARG} -lt 1 ]; then
echo "Usage: $0 argument"
echo "Argument = Script Name"
exit 1
elif
# If the argument passed is -h or --h then display the following message in the echo statement
[[ ${script_name} = "-h" ]] || [[ ${script_name} = "--h" ]]; then
echo "Usage: $0 argument"
echo "Argument = Script Name"
exit 1 # Quit the program
fi # End of the if statement
} # End of the function
funct_copy_file()
{
if [ ! -z $transfer_file ]; then
read -p "What server to you want to copy the file to : " SERVER
echo "Sending $transfer_file to $SERVER in /tmp"
scp $transfer_file $SERVER:/tmp
else
echo -e "File does not exist \n"
echo -e "A search for similar files shows :"
no_ext=`echo $script_name | cut -f1 -d.`
#echo $no_ext
new_search=`find ${scripts} -name *$no_ext* -print > /tmp/cr_list.txt` ; export new_search
for files in $(cat /tmp/cr_list.txt)
do
new_files=`basename $files`
echo $new_files
done
echo -e "\nWould you like to use one of these scripts? If so re-run the script and pass the correct script"
fi
}
################
# Main Program #
################
# Variable Settings
script_name=$1 ; export script_name
scripts=/export/home/craigdba/unicle/scripts ; export scripts
transfer_file=`find ${scripts} -name ${1} -print` ; export transfer_file
NARG=$#
{
funct_check_params
funct_copy_file
}
## End of Script