2009-10-06 23:43:57 +00:00
|
|
|
# $OpenBSD: sftp-batch.sh,v 1.4 2009/08/13 01:11:55 djm Exp $
|
2003-01-22 06:53:16 +00:00
|
|
|
# Placed in the Public Domain.
|
|
|
|
|
|
|
|
tid="sftp batchfile"
|
|
|
|
|
2003-09-06 23:28:03 +00:00
|
|
|
DATA=/bin/ls${EXEEXT}
|
2003-01-22 06:53:16 +00:00
|
|
|
COPY=${OBJ}/copy
|
2004-01-30 02:02:55 +00:00
|
|
|
BATCH=${OBJ}/sftp.bb
|
2003-01-22 06:53:16 +00:00
|
|
|
|
|
|
|
rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${BATCH}.*
|
|
|
|
|
|
|
|
cat << EOF > ${BATCH}.pass.1
|
|
|
|
get $DATA $COPY
|
|
|
|
put ${COPY} ${COPY}.1
|
|
|
|
rm ${COPY}
|
|
|
|
-put ${COPY} ${COPY}.2
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat << EOF > ${BATCH}.pass.2
|
|
|
|
# This is a comment
|
|
|
|
|
|
|
|
# That was a blank line
|
|
|
|
ls
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat << EOF > ${BATCH}.fail.1
|
|
|
|
get $DATA $COPY
|
|
|
|
put ${COPY} ${COPY}.3
|
|
|
|
rm ${COPY}.*
|
|
|
|
# The next command should fail
|
|
|
|
put ${COPY}.3 ${COPY}.4
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat << EOF > ${BATCH}.fail.2
|
|
|
|
# The next command should fail
|
|
|
|
jajajajaja
|
|
|
|
EOF
|
|
|
|
|
|
|
|
verbose "$tid: good commands"
|
2009-10-06 23:43:57 +00:00
|
|
|
${SFTP} -b ${BATCH}.pass.1 -D ${SFTPSERVER} >/dev/null 2>&1 \
|
2003-01-22 06:53:16 +00:00
|
|
|
|| fail "good commands failed"
|
|
|
|
|
|
|
|
verbose "$tid: bad commands"
|
2009-10-06 23:43:57 +00:00
|
|
|
${SFTP} -b ${BATCH}.fail.1 -D ${SFTPSERVER} >/dev/null 2>&1 \
|
2003-01-22 06:53:16 +00:00
|
|
|
&& fail "bad commands succeeded"
|
|
|
|
|
|
|
|
verbose "$tid: comments and blanks"
|
2009-10-06 23:43:57 +00:00
|
|
|
${SFTP} -b ${BATCH}.pass.2 -D ${SFTPSERVER} >/dev/null 2>&1 \
|
2003-01-22 06:53:16 +00:00
|
|
|
|| fail "comments & blanks failed"
|
|
|
|
|
|
|
|
verbose "$tid: junk command"
|
2009-10-06 23:43:57 +00:00
|
|
|
${SFTP} -b ${BATCH}.fail.2 -D ${SFTPSERVER} >/dev/null 2>&1 \
|
2003-01-22 06:53:16 +00:00
|
|
|
&& fail "junk command succeeded"
|
|
|
|
|
|
|
|
rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${BATCH}.*
|
|
|
|
|
|
|
|
|