免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2082 | 回复: 1
打印 上一主题 下一主题

[文本处理] 问题求助,奇怪的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-01-21 11:36 |只看该作者 |倒序浏览
脚本如下

#!/bin/sh

sql="/usr/bin/mysql -h127.0.0.1 -P3306 -uroot -p123456 test -e\"insert into t1(f1,f2,f3,f4) values('1','2','3','4')\""
echo $sql
$sql

exit 0
~

执行提示错误:
/usr/bin/mysql -h127.0.0.1 -P3306 -uroot -p123456 test -e"insert into t1(f1,f2,f3,f4) values('1','2','3','4')"
/usr/bin/mysql  Ver 14.14 Distrib 5.1.71, for redhat-linux-gnu (x86_64) using readline 5.1
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Usage: /usr/bin/mysql [OPTIONS] [database]

我理解是语句没完全识别,我想让它完整执行,该怎么写?求助!!!

论坛徽章:
4
技术图书徽章
日期:2013-09-23 10:22:37狮子座
日期:2013-10-15 23:31:54卯兔
日期:2013-11-11 17:33:15金牛座
日期:2013-11-15 17:25:28
2 [报告]
发表于 2014-01-21 12:16 |只看该作者
试试这个
  1. #!/bin/bash

  2. sql="/usr/bin/mysql -h127.0.0.1 -P3306 -uroot -p123456 test -e\"insert into t1(f1,f2,f3,f4) values('1','2','3','4')\""
  3. echo $sql
  4. eval $sql

  5. exit 0
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP