[英]MySQL: how to run shell command from .SQL script file
Running with MySQL 5.6.36 on Windows 10, I am writing a script in .sql file. 我正在Windows 10上使用MySQL 5.6.36运行,我正在.sql文件中编写脚本。 I need to run some shell command (in this case to concatenate two files). 我需要运行一些shell命令(在这种情况下,要连接两个文件)。
How can i do it? 我该怎么做?
I tried this but it gives "compilation error": 我试过了,但它给出了“编译错误”:
\! ls
It says: 它说:
Syntax error: '\\' escape operator is not valid input at this position 语法错误:“ \\”转义运算符在此位置无效输入
I can't reproduce the error: 我无法重现错误:
File: /path/to/file/test.sql
文件: /path/to/file/test.sql
SELECT VERSION();
SELECT 'system' `system`;
system ls -al myDir
SELECT '\\!';
\! ls -al myDir
MySQL Command Line: MySQL命令行:
mysql> \. /path/to/file/test.sql
+-----------+
| VERSION() |
+-----------+
| 5.7.11 |
+-----------+
1 row in set (0.00 sec)
+--------+
| system |
+--------+
| system |
+--------+
1 row in set (0.00 sec)
total 0
dr-------- 2 user user 10 Jan 12 00:00 .
dr-------- 23 user user 280 Jan 13 23:00 ..
+----+
| \! |
+----+
| \! |
+----+
1 row in set (0.00 sec)
total 0
dr-------- 2 user user 10 Jan 12 00:00 .
dr-------- 23 user user 280 Jan 13 23:00 ..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.