summary refs log tree commit diff
path: root/Functions/Zftp/zfstat
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-04-25 15:43:45 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-04-25 15:43:45 +0000
commite8eb43fc308acb3f1a8ebada7633c097e5050e46 (patch)
tree2df36ef3c7709c7d4d3b7bdcb5761f98649859bf /Functions/Zftp/zfstat
parente74702b467171dbdafb56dfe354794a212e020d9 (diff)
downloadzsh-e8eb43fc308acb3f1a8ebada7633c097e5050e46.tar.gz
zsh-e8eb43fc308acb3f1a8ebada7633c097e5050e46.tar.xz
zsh-e8eb43fc308acb3f1a8ebada7633c097e5050e46.zip
Initial revision
Diffstat (limited to 'Functions/Zftp/zfstat')
-rw-r--r--Functions/Zftp/zfstat89
1 files changed, 89 insertions, 0 deletions
diff --git a/Functions/Zftp/zfstat b/Functions/Zftp/zfstat
new file mode 100644
index 000000000..0ca755d03
--- /dev/null
+++ b/Functions/Zftp/zfstat
@@ -0,0 +1,89 @@
+# function zfstat {
+# Give a zftp status report using local variables.
+# With option -v, connect to the remote host and ask it what it
+# thinks the status is.  
+
+setopt localoptions unset
+unsetopt ksharrays
+
+local i stat=0 opt optlist verbose
+
+while [[ $1 = -* ]]; do
+  if [[ $1 = - || $1 = -- ]]; then
+    shift;
+    break;
+  fi
+  optlist=${1#-}
+  for (( i = 1; i <= $#optlist; i++)); do
+    opt=$optlist[$i]
+    case $opt in
+      v) verbose=1
+	 ;;
+      *) print option $opt not recognised >&2
+	 ;;
+    esac
+  done
+  shift
+done
+
+if [[ -n $ZFTP_HOST ]]; then
+  print "Host:\t\t$ZFTP_HOST"
+  print "IP:\t\t$ZFTP_IP"
+  [[ -n $ZFTP_SYSTEM ]] && print "System type:\t$ZFTP_SYSTEM"
+  if [[ -n $ZFTP_USER ]]; then
+    print "User:\t\t$ZFTP_USER "
+    [[ -n $ZFTP_ACCOUNT ]] && print "Account:\t$AFTP_ACCOUNT"
+    print "Directory:\t$ZFTP_PWD"
+    print -n "Transfer type:\t"
+    if [[ $ZFTP_TYPE = "I" ]]; then
+      print Image
+    elif [[ $ZFTP_TYPE = "A" ]]; then
+      print Ascii
+    else
+      print Unknown
+    fi
+    print -n "Transfer mode:\t"
+    if [[ $ZFTP_MODE = "S" ]]; then
+      print Stream
+    elif [[ $ZFTP_MODE = "B" ]]; then
+      print Block
+    else
+      print Unknown
+    fi
+  else
+    print "No user logged in."
+  fi
+else
+  print "Not connected."
+  [[ -n $zflastsession ]] && print "Last session:\t$zflastsession"
+  stat=1
+fi
+
+# things which may be set even if not connected:
+[[ -n $ZFTP_REPLY ]] && print "Last reply:\t$ZFTP_REPLY"
+print "Verbosity:\t$ZFTP_VERBOSE"
+print "Timeout:\t$ZFTP_TMOUT"
+print -n "Preferences:\t"
+for (( i = 1; i <= ${#ZFTP_PREFS}; i++ )); do
+  case $ZFTP_PREFS[$i] in
+    [pP]) print -n "Passive "
+	  ;;
+    [sS]) print -n "Sendport "
+	  ;;
+    [dD]) print -n "Dumb "
+	  ;;
+    *) print -n "$ZFTP_PREFS[$i]???"
+  esac
+done
+print
+
+if [[ -n $ZFTP_HOST && $verbose = 1 ]]; then
+  zfautocheck -d
+  print "Status of remote server:"
+  # make sure we print the reply
+  local ZFTP_VERBOSE=045
+  zftp quote STAT
+fi
+
+return $stat
+# }