initial commit
This commit is contained in:
100
chapter6/ftp-ls-getfile.exp
Executable file
100
chapter6/ftp-ls-getfile.exp
Executable file
@@ -0,0 +1,100 @@
|
||||
#!/usr/local/bin/expect -f
|
||||
#
|
||||
# This Expect script was generated by autoexpect on Fri Nov 16 12:29:38 2007
|
||||
# Expect and autoexpect were both written by Don Libes, NIST.
|
||||
#
|
||||
# Note that autoexpect does not guarantee a working script. It
|
||||
# necessarily has to guess about certain things. Two reasons a script
|
||||
# might fail are:
|
||||
#
|
||||
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
|
||||
# etc.) and devices discard or ignore keystrokes that arrive "too
|
||||
# quickly" after prompts. If you find your new script hanging up at
|
||||
# one spot, try adding a short sleep just before the previous send.
|
||||
# Setting "force_conservative" to 1 (see below) makes Expect do this
|
||||
# automatically - pausing briefly before sending each character. This
|
||||
# pacifies every program I know of. The -c flag makes the script do
|
||||
# this in the first place. The -C flag allows you to define a
|
||||
# character to toggle this mode off and on.
|
||||
|
||||
set force_conservative 0 ;# set to 1 to force conservative mode even if
|
||||
;# script wasn't run conservatively originally
|
||||
if {$force_conservative} {
|
||||
set send_slow {1 .1}
|
||||
proc send {ignore arg} {
|
||||
sleep .1
|
||||
exp_send -s -- $arg
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# 2) differing output - Some programs produce different output each time
|
||||
# they run. The "date" command is an obvious example. Another is
|
||||
# ftp, if it produces throughput statistics at the end of a file
|
||||
# transfer. If this causes a problem, delete these patterns or replace
|
||||
# them with wildcards. An alternative is to use the -p flag (for
|
||||
# "prompt") which makes Expect only look for the last line of output
|
||||
# (i.e., the prompt). The -P flag allows you to define a character to
|
||||
# toggle this mode off and on.
|
||||
#
|
||||
# Read the man page for more info.
|
||||
#
|
||||
# -Don
|
||||
|
||||
|
||||
set timeout -1
|
||||
spawn $env(SHELL)
|
||||
match_max 100000
|
||||
expect -exact "\]0;root@yogi:/scripts\[root@yogi scripts\]# "
|
||||
send -- "ftp booboo\r"
|
||||
expect -exact "ftp booboo\r
|
||||
Connected to booboo.\r
|
||||
220 (vsFTPd 1.2.1)\r
|
||||
530 Please login with USER and PASS.\r
|
||||
530 Please login with USER and PASS.\r
|
||||
KERBEROS_V4 rejected as an authentication type\r
|
||||
Name (booboo:root): "
|
||||
send -- "ftpadmin\r"
|
||||
expect -exact "ftpadmin\r
|
||||
331 Please specify the password.\r
|
||||
Password:"
|
||||
send -- "abc1234\r"
|
||||
expect -exact "\r
|
||||
230 Login successful.\r
|
||||
Remote system type is UNIX.\r
|
||||
Using binary mode to transfer files.\r
|
||||
ftp> "
|
||||
send -- "ls\r"
|
||||
expect -exact "ls\r
|
||||
227 Entering Passive Mode (192,167,37,43,182,234)\r
|
||||
150 Here comes the directory listing.\r
|
||||
-rw-r--r-- 1 4465 4465 29187 Sep 06 21:52 Linux_booboo_cronlistings.txt\r
|
||||
-rwxr-xr-x 1 4465 4465 1238 Sep 06 19:51 cron_capture\r
|
||||
-rwxr-xr-x 1 4465 4465 1230 Sep 06 20:23 cron_capture-LINUX\r
|
||||
-rw-r--r-- 1 0 0 84 Apr 03 2007 drinfo.sh\r
|
||||
-rw-rw-r-- 1 4465 4465 368535 Sep 07 20:40 get_AIX_sysinfo.log\r
|
||||
-rw-rw-r-- 1 4465 4465 205 Sep 07 15:48 get_dr_info.ksh\r
|
||||
-rw-rw-r-- 1 4465 4465 10933 Sep 07 20:35 get_sysinfo2.log\r
|
||||
-rw-r--r-- 1 0 0 666 Apr 03 2007 getall.sh\r
|
||||
-rw-r--r-- 1 0 0 256 Apr 03 2007 imp.sh\r
|
||||
-rw-r--r-- 1 0 0 323 Apr 03 2007 pb_getnet.sh\r
|
||||
-rw-r--r-- 1 0 0 167 Apr 03 2007 pb_getvg.sh\r
|
||||
-rw-r--r-- 1 0 0 618 Apr 03 2007 putall.sh\r
|
||||
-rw-r--r-- 1 0 0 10240 Sep 07 15:50 scripts.tar\r
|
||||
-rw-r--r-- 1 0 0 32 Apr 03 2007 um.sh\r
|
||||
226 Directory send OK.\r
|
||||
ftp> "
|
||||
send -- "get getall.sh\r"
|
||||
expect -exact "get getall.sh\r
|
||||
local: getall.sh remote: getall.sh\r
|
||||
227 Entering Passive Mode (192,168,37,43,52,152)\r
|
||||
150 Opening BINARY mode data connection for getall.sh (666 bytes).\r
|
||||
226 File send OK.\r
|
||||
666 bytes received in 0.064 seconds (10 Kbytes/s)\r
|
||||
ftp> "
|
||||
send -- "bye\r"
|
||||
expect -exact "bye\r
|
||||
221 Goodbye.\r
|
||||
\]0;root@yogi:/scripts\[root@yogi scripts\]# "
|
||||
send -- ""
|
||||
expect eof
|
||||
10
chapter6/function_post_event
Executable file
10
chapter6/function_post_event
Executable file
@@ -0,0 +1,10 @@
|
||||
post_event ()
|
||||
{
|
||||
# Add anything that you want to execute in this function. You can
|
||||
# hardcode the tasks in this function or create an external shell
|
||||
# script and execute the external function here.
|
||||
|
||||
: # No-Op: The colon (:) is a No-Op character. It does nothing and
|
||||
# always produces a 0, zero, return code.
|
||||
}
|
||||
|
||||
10
chapter6/function_pre_event
Executable file
10
chapter6/function_pre_event
Executable file
@@ -0,0 +1,10 @@
|
||||
pre_event ()
|
||||
{
|
||||
# Add anything that you want to execute in this function. You can
|
||||
# hardcode the tasks in this function or create an external shell
|
||||
# script and execute the external function here.
|
||||
|
||||
: # No-Op: The colon (:) is a No-Op character. It does nothing and
|
||||
# always produces a 0, zero, return code.
|
||||
}
|
||||
|
||||
106
chapter6/get_ftp_files.ksh
Executable file
106
chapter6/get_ftp_files.ksh
Executable file
@@ -0,0 +1,106 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# SCRIPT: get_ftp_files.ksh
|
||||
# AUTHOR: Randy Michael
|
||||
# DATE: July 15, 2007
|
||||
# REV: 1.1.P
|
||||
#
|
||||
# PLATFORM: Not Platform Dependent
|
||||
#
|
||||
# PURPOSE: This shell script uses FTP to get a one or more remote
|
||||
# files from a remote machine.
|
||||
#
|
||||
# set -n # Uncomment to check the script syntax without any execution
|
||||
# set -x # Uncomment to debug this shell script
|
||||
#
|
||||
###################################################################
|
||||
################## DEFINE VARIABLES HERE ##########################
|
||||
###################################################################
|
||||
|
||||
REMOTEFILES=$1
|
||||
|
||||
THISSCRIPT=$(basename $0)
|
||||
RNODE="wilma"
|
||||
USER="randy"
|
||||
UPASSWD="mypassword"
|
||||
LOCALDIR="/scripts/download"
|
||||
REMOTEDIR="/scripts"
|
||||
|
||||
# Set up the correct echo command usage. Many Linux
|
||||
# distributions will execute in Bash even if the
|
||||
# script specifies Korn shell. Bash shell requires
|
||||
# we use echo -e when we use \n, \c, etc.
|
||||
|
||||
case $(basename $SHELL) in
|
||||
bash) alias echo="echo -e"
|
||||
;;
|
||||
esac
|
||||
|
||||
###################################################################
|
||||
################## DEFINE FUNCTIONS HERE ##########################
|
||||
###################################################################
|
||||
|
||||
pre_event ()
|
||||
{
|
||||
# Add anything that you want to execute in this function. You can
|
||||
# hardcode the tasks in this function or create an external shell
|
||||
# script and execute the external function here.
|
||||
|
||||
: # No-Op: The colon (:) is a No-Op character. It does nothing and
|
||||
# always produces a 0, zero, return code.
|
||||
}
|
||||
|
||||
###################################################################
|
||||
|
||||
post_event ()
|
||||
{
|
||||
# Add anything that you want to execute in this function. You can
|
||||
# hardcode the tasks in this function or create an external shell
|
||||
# script and execute the external function here.
|
||||
|
||||
: # No-Op: The colon (:) is a No-Op character. It does nothing and
|
||||
# always produces a 0, zero, return code.
|
||||
}
|
||||
|
||||
###################################################################
|
||||
|
||||
usage ()
|
||||
{
|
||||
echo "\nUSAGE: $THISSCRIPT \"One or More Filenames to Download\" \n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
###################################################################
|
||||
|
||||
usage_error ()
|
||||
{
|
||||
echo "\nERROR: This shell script requires a list of one or more
|
||||
files to download from the remote site.\n"
|
||||
|
||||
usage
|
||||
}
|
||||
|
||||
###################################################################
|
||||
##################### BEGINNING OF MAIN ###########################
|
||||
###################################################################
|
||||
|
||||
# Test for a single command-line argument. This should contain a list
|
||||
# of one or more files.
|
||||
|
||||
(($# != 1)) && usage_error
|
||||
|
||||
pre_event
|
||||
|
||||
ftp -i -v -n $RNODE <<END_FTP
|
||||
|
||||
user $USER $UPASSWD
|
||||
binary
|
||||
lcd $LOCALDIR
|
||||
cd $REMOTEDIR
|
||||
mget $REMOTEFILES
|
||||
bye
|
||||
|
||||
END_FTP
|
||||
|
||||
post_event
|
||||
|
||||
110
chapter6/get_ftp_files_pw_var.ksh
Executable file
110
chapter6/get_ftp_files_pw_var.ksh
Executable file
@@ -0,0 +1,110 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# SCRIPT: get_ftp_files_pw_var.ksh
|
||||
# AUTHOR: Randy Michael
|
||||
# DATE: July 15, 2007
|
||||
# REV: 1.1.P
|
||||
#
|
||||
# PLATFORM: Not Platform Dependent
|
||||
#
|
||||
# PURPOSE: This shell script uses FTP to get a one or more remote
|
||||
# files from a remote machine. This shell script uses a
|
||||
# remotely defined password variable.
|
||||
#
|
||||
# set -n # Uncomment to check the script syntax without any execution
|
||||
# set -x # Uncomment to debug this shell script
|
||||
#
|
||||
###################################################################
|
||||
################## DEFINE VARIABLES HERE ##########################
|
||||
###################################################################
|
||||
|
||||
REMOTEFILES=$1
|
||||
|
||||
THISSCRIPT=$(basename $0)
|
||||
RNODE="wilma"
|
||||
USER="randy"
|
||||
LOCALDIR="/scripts/download"
|
||||
REMOTEDIR="/scripts"
|
||||
|
||||
# Set up the correct echo command usage. Many Linux
|
||||
# distributions will execute in Bash even if the
|
||||
# script specifies Korn shell. Bash shell requires
|
||||
# we use echo -e when we use \n, \c, etc.
|
||||
|
||||
case $SHELL in
|
||||
*/bin/bash) alias echo="echo -e"
|
||||
;;
|
||||
esac
|
||||
|
||||
###################################################################
|
||||
################## DEFINE FUNCTIONS HERE ##########################
|
||||
###################################################################
|
||||
|
||||
pre_event ()
|
||||
{
|
||||
# Add anything that you want to execute in this function. You can
|
||||
# hardcode the tasks in this function or create an external shell
|
||||
# script and execute the external function here.
|
||||
|
||||
: # No-Op: The colon (:) is a No-Op character. It does nothing and
|
||||
# always produces a 0, zero, return code.
|
||||
}
|
||||
|
||||
###################################################################
|
||||
|
||||
post_event ()
|
||||
{
|
||||
# Add anything that you want to execute in this function. You can
|
||||
# hardcode the tasks in this function or create an external shell
|
||||
# script and execute the external function here.
|
||||
|
||||
: # No-Op: The colon (:) is a No-Op character. It does nothing and
|
||||
# always produces a 0, zero, return code.
|
||||
}
|
||||
|
||||
###################################################################
|
||||
|
||||
usage ()
|
||||
{
|
||||
echo "\nUSAGE: $THISSCRIPT \"One or More Filenames to Download\" \n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
###################################################################
|
||||
|
||||
usage_error ()
|
||||
{
|
||||
echo "\nERROR: This shell script requires a list of one or more
|
||||
files to download from the remote site.\n"
|
||||
|
||||
usage
|
||||
}
|
||||
|
||||
###################################################################
|
||||
##################### BEGINNING OF MAIN ###########################
|
||||
###################################################################
|
||||
|
||||
# Test for exactly one command-line argument. This should contain a
|
||||
# list of one or more files to act on.
|
||||
|
||||
(($# != 1)) && usage_error
|
||||
|
||||
# Get a password
|
||||
|
||||
. /usr/sbin/setlink.ksh
|
||||
|
||||
pre_event
|
||||
|
||||
ftp -i -v -n $RNODE <<END_FTP
|
||||
|
||||
user $USER $RANDY
|
||||
binary
|
||||
lcd $LOCALDIR
|
||||
cd $REMOTEDIR
|
||||
mget $REMOTEFILES
|
||||
bye
|
||||
|
||||
END_FTP
|
||||
|
||||
post_event
|
||||
|
||||
38
chapter6/get_remote_dir_listing.ksh
Executable file
38
chapter6/get_remote_dir_listing.ksh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# SCRIPT: get_remote_dir_listing.ksh
|
||||
# AUTHOR: Randy Michael
|
||||
# DATE: July 15, 2007
|
||||
# REV: 1.1.P
|
||||
#
|
||||
# PLATFORM: Not Platform Dependent
|
||||
#
|
||||
# PURPOSE: This shell script uses FTP to get a remote directory listing
|
||||
# and save this list in a local file.
|
||||
#
|
||||
# set -n # Uncomment to check the script syntax without any execution
|
||||
# set -x # Uncomment to debug this shell script
|
||||
#
|
||||
###################################################################
|
||||
################## DEFINE VARIABLES HERE ##########################
|
||||
###################################################################
|
||||
|
||||
RNODE="wilma"
|
||||
USER="randy"
|
||||
UPASSWD="mypassword"
|
||||
LOCALDIR="/scripts/download"
|
||||
REMOTEDIR="/scripts"
|
||||
DIRLISTFILE="${LOCALDIR}/${RNODE}.$(basename ${REMOTEDIR}).dirlist.out"
|
||||
cat /dev/null > $DIRLISTFILE
|
||||
|
||||
###################################################################
|
||||
##################### BEGINNING OF MAIN ###########################
|
||||
###################################################################
|
||||
|
||||
ftp -i -v -n $RNODE <<END_FTP
|
||||
user $USER $UPASSWD
|
||||
nlist $REMOTEDIR $DIRLISTFILE
|
||||
bye
|
||||
|
||||
END_FTP
|
||||
|
||||
42
chapter6/get_remote_dir_listing_pw_var.ksh
Executable file
42
chapter6/get_remote_dir_listing_pw_var.ksh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# SCRIPT: get_remote_dir_listing.ksh
|
||||
# AUTHOR: Randy Michael
|
||||
# DATE: July 15, 2007
|
||||
# REV: 1.1.P
|
||||
#
|
||||
# PLATFORM: Not Platform Dependent
|
||||
#
|
||||
# PURPOSE: This shell script uses FTP to get a remote directory listing
|
||||
# and save this list in a local file. This shell script uses
|
||||
# remotely defined passwords.
|
||||
#
|
||||
# set -n # Uncomment to check the script syntax without any execution
|
||||
# set -x # Uncomment to debug this shell script
|
||||
#
|
||||
###################################################################
|
||||
################## DEFINE VARIABLES HERE ##########################
|
||||
###################################################################
|
||||
|
||||
RNODE="wilma"
|
||||
USER="randy"
|
||||
LOCALDIR="/scripts/download"
|
||||
REMOTEDIR="/scripts"
|
||||
DIRLISTFILE="${LOCALDIR}/${RNODE}.$(basename ${REMOTEDIR}).dirlist.out"
|
||||
cat /dev/null > $DIRLISTFILE
|
||||
|
||||
###################################################################
|
||||
##################### BEGINNING OF MAIN ###########################
|
||||
###################################################################
|
||||
|
||||
# Get a password
|
||||
|
||||
. /usr/sbin/setlink.ksh
|
||||
|
||||
ftp -i -v -n $RNODE <<END_FTP
|
||||
user $USER $RANDY
|
||||
nlist $REMOTEDIR $DIRLISTFILE
|
||||
bye
|
||||
|
||||
END_FTP
|
||||
|
||||
108
chapter6/put_ftp_files.ksh
Executable file
108
chapter6/put_ftp_files.ksh
Executable file
@@ -0,0 +1,108 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# SCRIPT: put_ftp_files.ksh
|
||||
# AUTHOR: Randy Michael
|
||||
# DATE: July 15, 2007
|
||||
# REV: 1.1.P
|
||||
#
|
||||
# PLATFORM: Not Platform Dependent
|
||||
#
|
||||
# PURPOSE: This shell script uses FTP to put a list of one or more
|
||||
# local files to a remote machine.
|
||||
#
|
||||
# set -n # Uncomment to check the script syntax without any execution
|
||||
# set -x # Uncomment to debug this shell script
|
||||
#
|
||||
###################################################################
|
||||
################## DEFINE VARIABLES HERE ##########################
|
||||
###################################################################
|
||||
|
||||
LOCALFILES=$1
|
||||
|
||||
THISSCRIPT=$(basename $0)
|
||||
RNODE="wilma"
|
||||
USER="randy"
|
||||
UPASSWD="mypassword"
|
||||
LOCALDIR="/scripts"
|
||||
REMOTEDIR="/scripts/download"
|
||||
|
||||
# Set up the correct echo command usage. Many Linux
|
||||
# distributions will execute in Bash even if the
|
||||
# script specifies Korn shell. Bash shell requires
|
||||
# we use echo -e when we use \n, \c, etc.
|
||||
|
||||
case $SHELL in
|
||||
*/bin/bash) alias echo="echo -e"
|
||||
;;
|
||||
esac
|
||||
|
||||
###################################################################
|
||||
################## DEFINE FUNCTIONS HERE ##########################
|
||||
###################################################################
|
||||
|
||||
pre_event ()
|
||||
{
|
||||
# Add anything that you want to execute in this function. You can
|
||||
# hardcode the tasks in this function or create an external shell
|
||||
# script and execute the external function here.
|
||||
|
||||
: # No-Op: The colon (:) is a No-Op character. It does nothing and
|
||||
# always produces a 0, zero, return code.
|
||||
}
|
||||
|
||||
###################################################################
|
||||
|
||||
post_event ()
|
||||
{
|
||||
# Add anything that you want to execute in this function. You can
|
||||
# hardcode the tasks in this function or create an external shell
|
||||
# script and execute the external function here.
|
||||
|
||||
: # No-Op: The colon (:) is a No-Op character. It does nothing and
|
||||
# always produces a 0, zero, return code.
|
||||
}
|
||||
|
||||
###################################################################
|
||||
|
||||
usage ()
|
||||
{
|
||||
echo "\nUSAGE: $THISSCRIPT \"One or More Filenames to Download\" \n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
###################################################################
|
||||
|
||||
usage_error ()
|
||||
{
|
||||
echo "\nERROR: This shell script requires a list of one or more
|
||||
files to download from the remote site.\n"
|
||||
|
||||
usage
|
||||
}
|
||||
|
||||
###################################################################
|
||||
##################### BEGINNING OF MAIN ###########################
|
||||
###################################################################
|
||||
|
||||
# Test to ensure that the file(s) is/are specified in the $1
|
||||
# command-line argument.
|
||||
|
||||
(($# != 1)) && usage_error
|
||||
|
||||
pre_event
|
||||
|
||||
# Connect to the remote site and begin the here document.
|
||||
|
||||
ftp -i -v -n $RNODE <<END_FTP
|
||||
|
||||
user $USER $UPASSWD
|
||||
binary
|
||||
lcd $LOCALDIR
|
||||
cd $REMOTEDIR
|
||||
mput $LOCALFILES
|
||||
bye
|
||||
|
||||
END_FTP
|
||||
|
||||
post_event
|
||||
|
||||
113
chapter6/put_ftp_files_pw_var.ksh
Executable file
113
chapter6/put_ftp_files_pw_var.ksh
Executable file
@@ -0,0 +1,113 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# SCRIPT: put_ftp_files_pw_var.ksh
|
||||
# AUTHOR: Randy Michael
|
||||
# DATE: July 15, 2007
|
||||
# REV: 1.1.P
|
||||
#
|
||||
# PLATFORM: Not Platform Dependent
|
||||
#
|
||||
# PURPOSE: This shell script uses FTP to put a list of one or more
|
||||
# local files to a remote machine. This shell script uses
|
||||
# remotely defined password variables
|
||||
#
|
||||
# set -n # Uncomment to check the script syntax without any execution
|
||||
# set -x # Uncomment to debug this shell script
|
||||
#
|
||||
###################################################################
|
||||
################## DEFINE VARIABLES HERE ##########################
|
||||
###################################################################
|
||||
|
||||
LOCALFILES=$1
|
||||
|
||||
THISSCRIPT=$(basename $0)
|
||||
RNODE="wilma"
|
||||
USER="randy"
|
||||
LOCALDIR="/scripts"
|
||||
REMOTEDIR="/scripts/download"
|
||||
|
||||
# Set up the correct echo command usage. Many Linux
|
||||
# distributions will execute in Bash even if the
|
||||
# script specifies Korn shell. Bash shell requires
|
||||
# we use echo -e when we use \n, \c, etc.
|
||||
|
||||
case $SHELL in
|
||||
*/bin/bash) alias echo="echo -e"
|
||||
;;
|
||||
esac
|
||||
|
||||
###################################################################
|
||||
################## DEFINE FUNCTIONS HERE ##########################
|
||||
###################################################################
|
||||
|
||||
pre_event ()
|
||||
{
|
||||
# Add anything that you want to execute in this function. You can
|
||||
# hardcode the tasks in this function or create an external shell
|
||||
# script and execute the external function here.
|
||||
|
||||
: # No-Op: The colon (:) is a No-Op character. It does nothing and
|
||||
# always produces a 0, zero, return code.
|
||||
}
|
||||
|
||||
###################################################################
|
||||
|
||||
post_event ()
|
||||
{
|
||||
# Add anything that you want to execute in this function. You can
|
||||
# hardcode the tasks in this function or create an external shell
|
||||
# script and execute the external function here.
|
||||
|
||||
: # No-Op: The colon (:) is a No-Op character. It does nothing and
|
||||
# always produces a 0, zero, return code.
|
||||
}
|
||||
|
||||
###################################################################
|
||||
|
||||
usage ()
|
||||
{
|
||||
echo "\nUSAGE: $THISSCRIPT \"One or More Filenames to Download\" \n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
###################################################################
|
||||
|
||||
usage_error ()
|
||||
{
|
||||
echo "\nERROR: This shell script requires a list of one or more
|
||||
files to download from the remote site.\n"
|
||||
|
||||
usage
|
||||
}
|
||||
|
||||
###################################################################
|
||||
##################### BEGINNING OF MAIN ###########################
|
||||
###################################################################
|
||||
|
||||
# Test to ensure that the file(s) is/are specified in the $1
|
||||
# command-line argument.
|
||||
|
||||
(($# != 1)) && usage_error
|
||||
|
||||
# Get a password
|
||||
|
||||
. /usr/sbin/setlink.ksh
|
||||
|
||||
|
||||
pre_event
|
||||
|
||||
# Connect to the remote site and begin the here document.
|
||||
|
||||
ftp -i -v -n $RNODE <<END_FTP
|
||||
|
||||
user $USER $RANDY
|
||||
binary
|
||||
lcd $LOCALDIR
|
||||
cd $REMOTEDIR
|
||||
mput $LOCALFILES
|
||||
bye
|
||||
|
||||
END_FTP
|
||||
|
||||
post_event
|
||||
|
||||
28
chapter6/search_group_id.bash
Executable file
28
chapter6/search_group_id.bash
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT: search_group_id.bash
|
||||
# AUTHOR: Randy Michael
|
||||
# DATE: 14/4/2007
|
||||
# REV: 1.0
|
||||
# PURPOSE: This script is used to list the group(s) associated
|
||||
# with each user defined in the /etc/passwd file.
|
||||
#
|
||||
#
|
||||
###########################################
|
||||
# DECLARE FILES AND VARIABLES HERE
|
||||
###########################################
|
||||
|
||||
case $(uname) in
|
||||
SunOS) alias awk=nawk
|
||||
;;
|
||||
esac
|
||||
|
||||
#########################################
|
||||
# BEGINNING OF MAIN
|
||||
#########################################
|
||||
|
||||
cat /etc/passwd | awk -F : '{print $1}' | while read ID
|
||||
do
|
||||
echo -e "${ID}: \c"
|
||||
id -Gn $ID
|
||||
done
|
||||
38
chapter6/sftp-scp-getfile.bash
Executable file
38
chapter6/sftp-scp-getfile.bash
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# SCRIPT: sftp-scp-getfile.bash
|
||||
# AUTHOR: Randy Michael
|
||||
# DATE: 11/15/2007
|
||||
# REV: 1.0
|
||||
#
|
||||
# PURPOSE: This is a simple script to show how
|
||||
# Secure FTP and Secure Copy work with and
|
||||
# without passwords. This is done by removing
|
||||
# and adding the remote host's key in the local
|
||||
# $HOME/.ssh/known_hosts file.
|
||||
#
|
||||
####################################
|
||||
# DEFINE FILES AND VARIABLES HERE
|
||||
####################################
|
||||
|
||||
COPYMGR=ftpadmin
|
||||
REM_MACHINE=booboo
|
||||
REM_FILE=/home/ftpadmin/getall.sh
|
||||
LOC_FILE=$HOME # Use the same filename but
|
||||
# store the file in $COPYMGR
|
||||
# $HOME directory.
|
||||
|
||||
####################################
|
||||
# BEGINNING OF MAIN
|
||||
####################################
|
||||
|
||||
echo -e "\nSecure FTP Method\n"
|
||||
|
||||
sftp ${COPYMGR}@${REM_MACHINE}:$REM_FILE $LOC_FILE
|
||||
|
||||
echo -e "\nSecure Copy Method\n"
|
||||
|
||||
scp ${COPYMGR}@${REM_MACHINE}:$REM_FILE $LOC_FILE
|
||||
|
||||
echo -n
|
||||
|
||||
26
chapter6/tst_ftp.ksh
Executable file
26
chapter6/tst_ftp.ksh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# SCRIPT: tst_ftp.ksh
|
||||
# AUTHOR: Randy Michael
|
||||
# DATE: 6/12/2007
|
||||
# REV: 1.1.A
|
||||
# PLATOFRM: Not platform dependent
|
||||
#
|
||||
# PURPOSE: This shell script is a simple demostration of
|
||||
# using a here document in a shell script to automate
|
||||
# an FTP file transfer.
|
||||
#
|
||||
|
||||
# Connect to the remote machine and begin a here document.
|
||||
|
||||
ftp -i -v -n wilma <<END_FTP
|
||||
|
||||
user randy mypassword
|
||||
binary
|
||||
lcd /scripts/download
|
||||
cd /scripts
|
||||
get auto_ftp_xfer.ksh
|
||||
bye
|
||||
|
||||
END_FTP
|
||||
|
||||
Reference in New Issue
Block a user