运行调用另一个脚本的bash脚本时出现EOF错误
另一个脚本是read语句,它将从这个脚本返回到一个文件中运行调用另一个脚本的bash脚本时出现EOF错误,bash,scripting,Bash,Scripting,另一个脚本是read语句,它将从这个脚本返回到一个文件中 #!/usr/bin/bash # createdb_wrapper.scr # Log information about user of createdb.scr Default_Dir=/export/home/cwatts/test Default_Log=DB.Audit while [ -z "${fname}" ] do echo "Please, enter your Fullname [ENTER]:"
#!/usr/bin/bash
# createdb_wrapper.scr
# Log information about user of createdb.scr
Default_Dir=/export/home/cwatts/test
Default_Log=DB.Audit
while [ -z "${fname}" ]
do
echo "Please, enter your Fullname [ENTER]:"
read fname
done
尝试了各种方法从其他脚本中提取信息
dbname=“./createDB.scr | awk'{print$1}'”
你忘了另一句话:
echo "Please,enter a brief Description [ENTER]:
应该是
echo "Please,enter a brief Description [ENTER]:"
我也推荐这种形式:
#!/bin/bash
#
# createdb_wrapper.scr
# Log information about user of createdb.scr
#
DEFAULT_DIR='/export/home/cwatts/test'
DEFAULT_LOG='DB.Audit'
until read -p "Please, enter your Fullname [ENTER]: " FNAME && [[ -n $FNAME ]]; do
:
done
until read -p "Please,enter a brief Description [ENTER]: " DESC && [[ -n $DESC ]]; do
:
done
if [[ -d $DEFAULT_DIR ]]; then
echo "Directory does not exist. It will be created."
mkdir "$DEFAULT_DIR"
fi
echo "$(exec date -u) | $DBNAME | $FNAME | $DESC" >> "$DEFAULT_DIR/$DEFAULT_LOG"
注意:
$DBNAME
未设置。DOH,非常感谢
#!/bin/bash
#
# createdb_wrapper.scr
# Log information about user of createdb.scr
#
DEFAULT_DIR='/export/home/cwatts/test'
DEFAULT_LOG='DB.Audit'
until read -p "Please, enter your Fullname [ENTER]: " FNAME && [[ -n $FNAME ]]; do
:
done
until read -p "Please,enter a brief Description [ENTER]: " DESC && [[ -n $DESC ]]; do
:
done
if [[ -d $DEFAULT_DIR ]]; then
echo "Directory does not exist. It will be created."
mkdir "$DEFAULT_DIR"
fi
echo "$(exec date -u) | $DBNAME | $FNAME | $DESC" >> "$DEFAULT_DIR/$DEFAULT_LOG"