1# $OpenBSD: sftp-cmds.sh,v 1.2 2003/01/10 07:52:41 djm Exp $ 2# Placed in the Public Domain. 3 4# XXX - TODO: 5# - globbed operations 6# - chmod / chown / chgrp 7# - -p flag for get & put 8 9tid="sftp commands" 10 11DATA=/bin/ls 12COPY=${OBJ}/copy 13 14rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${BATCH}.* 15 16verbose "$tid: lls" 17echo "lls ${OBJ}" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 18 || fail "lls failed" 19# XXX always successful 20 21verbose "$tid: ls" 22echo "ls ${OBJ}" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 23 || fail "ls failed" 24# XXX always successful 25 26verbose "$tid: shell" 27echo "!echo hi there" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 28 || fail "shell failed" 29# XXX always successful 30 31verbose "$tid: pwd" 32echo "pwd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 33 || fail "pwd failed" 34# XXX always successful 35 36verbose "$tid: lpwd" 37echo "lpwd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 38 || fail "lpwd failed" 39# XXX always successful 40 41verbose "$tid: quit" 42echo "quit" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 43 || fail "quit failed" 44# XXX always successful 45 46verbose "$tid: help" 47echo "help" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 48 || fail "help failed" 49# XXX always successful 50 51rm -f ${COPY} 52verbose "$tid: get" 53echo "get $DATA $COPY" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 54 || fail "get failed" 55cmp $DATA ${COPY} || fail "corrupted copy after get" 56 57rm -f ${COPY} 58verbose "$tid: put" 59echo "put $DATA $COPY" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 60 || fail "put failed" 61cmp $DATA ${COPY} || fail "corrupted copy after put" 62 63verbose "$tid: rename" 64echo "rename $COPY ${COPY}.1" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 65 || fail "rename failed" 66test -f ${COPY}.1 || fail "missing file after rename" 67cmp $DATA ${COPY}.1 >/dev/null 2>&1 || fail "corrupted copy after rename" 68 69verbose "$tid: ln" 70echo "ln ${COPY}.1 ${COPY}.2" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "ln failed" 71test -L ${COPY}.2 || fail "missing file after ln" 72 73verbose "$tid: mkdir" 74echo "mkdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 75 || fail "mkdir failed" 76test -d ${COPY}.dd || fail "missing directory after mkdir" 77 78# XXX do more here 79verbose "$tid: chdir" 80echo "chdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 81 || fail "chdir failed" 82 83verbose "$tid: rmdir" 84echo "rmdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 85 || fail "rmdir failed" 86test -d ${COPY}.1 && fail "present directory after rmdir" 87 88verbose "$tid: lmkdir" 89echo "lmkdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 90 || fail "lmkdir failed" 91test -d ${COPY}.dd || fail "missing directory after lmkdir" 92 93# XXX do more here 94verbose "$tid: lchdir" 95echo "lchdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ 96 || fail "lchdir failed" 97 98rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${BATCH}.* 99 100 101