请大牛帮忙,shell脚本的问题

senlinzhiwang 2011-11-11 11:57:39
$vi test.sh
#!/bin/bash
table=xx_20$(date +%y%m)
echo $table
value=sqlplus ttt/ttt@ts <select count(*) from $table;
exit
EOF
echo $value
fi

然后
chmod 777 test.sh
./test.sh
出现:
xx_201111
./test.sh: line 4: select: A file or directory in the path name does not exist.

请各位帮忙看看,谢谢!!!!!

...全文
46 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
livesguan 2011-11-11
  • 打赏
  • 举报
回复
sqlplus ttt/ttt@ts?

ttt在你当前目录吗?
senlinzhiwang 2011-11-11
  • 打赏
  • 举报
回复
现在发现,如果这样写,就能够查询得到数据:
$vi test.sh
#!/bin/bash
table=xx_20$(date +%y%m)
echo $table
value=sqlplus ttt/ttt@ts <<EOF
set heading off
set pagesize 0;
set feedback off;
set verify off;
set echo off;
select * from $table;
exit
echo $value
fi

但是如果把sql写为:select count(*) from $table;
这样就查不了数据,报:A file or directory in the path name does not exist.
请求高见!谢谢
senlinzhiwang 2011-11-11
  • 打赏
  • 举报
回复
把EOF和FI去掉之后,还是同样的报错。是不是还要引入什么啊?
qq120848369 2011-11-11
  • 打赏
  • 举报
回复
看不懂。。。

EOF和fi是哪里来的。。
senlinzhiwang 2011-11-11
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 userguanguan 的回复:]
sqlplus ttt/ttt@ts?

ttt在你当前目录吗?
[/Quote]
那不是目录,那是数据库登陆用户名,后面是数据库名。

19,612

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧