问题:
我正在bash
从书中学习(Linux Shell Scripting with Bash,Ken O. Burch),我现在关注的这本书正在使用这个命令:
/usr/bin/statftime
但是我找不到适用于我的 Linux 的这个命令
我正在使用 Debian 9.0 stretch
问题:
你能告诉我这个命令吗?是否可以在 Debian 上安装它以及如何在 Debian 上安装它?
编辑:
bash
这本书是我读过的最好的书之一(Linux Shell Scripting with Bash,Ken O. Burch)(@Gilles)所以这可能不是一个技巧,我将在下面发布代码:
这是代码:
#!/bin/bash -x
#
# polling.sh: a daemon using polling to check for new files
shopt -s -o nounset
declare -rx SCRIPT=${0##*/}
declare -rx INCOMING_FTP_DIR="/home/ftp/ftp_incoming"
declare -rx PROCESSING_DIR="/home/ftp/processing"
declare -rx statftime="/usr/local/bin/statftime"
declare FILE=""
declare FILES=""
declare NEW_FILE=""
printf "$SCRIPT started at %s\n" "`date`"
# Sanity checks
if [[ ! -d /home/ftp/ftp_incoming ]] || [[ ! -d /home/ftp/processing ]]
then
mkdir -p /home/ftp/ftp_incoming
mkdir -p /home/ftp/processing
if [ "$?" -ne 0 ]
then
echo "You are a idiot"
else
echo "You succeded!"
fi
fi
if test ! -r "$INCOMING_FTP_DIR"
then
printf "%s\n" "$SCRIPT:$LINENO: unable to read the incoming directory --aborted" >&1
exit 1
fi
if test ! -r "$PROCESSING_DIR"
then
printf "%s\n" "$SCRIPT:$LINENO: unable to read the incoming directory --aborted" >&1
exit 1
fi
if test ! -r "$statftime"
then
printf "%s\n" "$SCRIPT:$LINENO: unable to find or execute $statftime --aborted" >&1
exit 1
fi
# Poll for new FTP files
cd $INCOMING_FTP_DIR
while true
do
#check for new files more than 30 minutes unchanged
FILES=`find . -type f -mmin +30 -print`
# If new files exist, move them to the processing directory
if [ ! -z "$FILES" ]
then
printf "$SCRIPT: new files have arrived at %s\n" "`date`"
printf "%s\n" "$FILES" |
{
while read FILE
do
# Remove leading "./"
FILE=${FILE##*/}
# Rename the file with the current time
NEW_FILE=`$statftime -f "%_L%_a_%T.dat" "$FILE"`
if [ -z "$NEW_FILE" ]
then
printf "%s\n" "$SCRIPT:$LINENO: statftime failed to create a new filename--skipping"
else
# Move the file to the processing directory
printf "%s\n" "$SCRIPT: moved $FILE to $PROCESSING_DIR/$NEW_FILE"
mv "$FILE" "$PROCESSING_DIR/$NEW_FILE"
fi
done
}
fi
sleep 30
done
printf "$SCRIPT finished unexpectedly at %s\n" "`date`"
exit 1
以下是有关命令的一些信息:
解决方案
通过Google 简单搜索 statftime 会返回您要查找的程序的软件供应商,作为第一个结果。 PegaSoft看起来是一个专注于 Linux 和Ada 编程语言的博客。
请注意,搜索
statftime debian
不会返回与 Debian 存储库相关的任何内容。安装说明需要build-essential 包,安装说明位于:Debian Linux Install GNU GCC Compiler and Development Environment。在你书中的某个地方,我确定该链接以脚注等形式存在。