下面我尝试自动化 Sybase 报告作业,但无法获取变量值作为 sp_helpdb proc 的参数。
#!/bin/sh
. ./SYBASE.sh
dblist=`isql -S syb157134 -Usa -b -P << endit
use master
go
set nocount on
go
select name
from sysdatabases
go
exit
endit
`
for db in $dblist
do
if [ -n "$dblist" ]; then
`isql -S syb157134 -Usa -b -P <<EOF > /sybase/pankaj/INPUT/sp_helpdb_$db.txt
use master
go
sp_helpdb "$db" ------not able to get the $db variable value
go
exit
endit
EOF
`
else
echo "Array empty"
fi
done
答案1
引号中的变量不会在定界文档内展开。您应该删除双引号"$db"