Darren Tucker | 46662bf | 2004-01-30 13:02:55 +1100 | [diff] [blame] | 1 | # $OpenBSD: sftp-batch.sh,v 1.3 2004/01/13 09:49:06 djm Exp $ |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 2 | # Placed in the Public Domain. |
| 3 | |
| 4 | tid="sftp batchfile" |
| 5 | |
Darren Tucker | d199b6d | 2003-09-07 09:28:03 +1000 | [diff] [blame] | 6 | DATA=/bin/ls${EXEEXT} |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 7 | COPY=${OBJ}/copy |
Darren Tucker | 46662bf | 2004-01-30 13:02:55 +1100 | [diff] [blame] | 8 | BATCH=${OBJ}/sftp.bb |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 9 | |
| 10 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${BATCH}.* |
| 11 | |
| 12 | cat << EOF > ${BATCH}.pass.1 |
| 13 | get $DATA $COPY |
| 14 | put ${COPY} ${COPY}.1 |
| 15 | rm ${COPY} |
| 16 | -put ${COPY} ${COPY}.2 |
| 17 | EOF |
| 18 | |
| 19 | cat << EOF > ${BATCH}.pass.2 |
| 20 | # This is a comment |
| 21 | |
| 22 | # That was a blank line |
| 23 | ls |
| 24 | EOF |
| 25 | |
| 26 | cat << EOF > ${BATCH}.fail.1 |
| 27 | get $DATA $COPY |
| 28 | put ${COPY} ${COPY}.3 |
| 29 | rm ${COPY}.* |
| 30 | # The next command should fail |
| 31 | put ${COPY}.3 ${COPY}.4 |
| 32 | EOF |
| 33 | |
| 34 | cat << EOF > ${BATCH}.fail.2 |
| 35 | # The next command should fail |
| 36 | jajajajaja |
| 37 | EOF |
| 38 | |
| 39 | verbose "$tid: good commands" |
| 40 | ${SFTP} -b ${BATCH}.pass.1 -P ${SFTPSERVER} >/dev/null 2>&1 \ |
| 41 | || fail "good commands failed" |
| 42 | |
| 43 | verbose "$tid: bad commands" |
| 44 | ${SFTP} -b ${BATCH}.fail.1 -P ${SFTPSERVER} >/dev/null 2>&1 \ |
| 45 | && fail "bad commands succeeded" |
| 46 | |
| 47 | verbose "$tid: comments and blanks" |
| 48 | ${SFTP} -b ${BATCH}.pass.2 -P ${SFTPSERVER} >/dev/null 2>&1 \ |
| 49 | || fail "comments & blanks failed" |
| 50 | |
| 51 | verbose "$tid: junk command" |
| 52 | ${SFTP} -b ${BATCH}.fail.2 -P ${SFTPSERVER} >/dev/null 2>&1 \ |
| 53 | && fail "junk command succeeded" |
| 54 | |
| 55 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${BATCH}.* |
| 56 | |
| 57 | |