Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 测试中导致测试未完全退出的命令_Mysql_Macos_Perl - Fatal编程技术网

Mysql 测试中导致测试未完全退出的命令

Mysql 测试中导致测试未完全退出的命令,mysql,macos,perl,Mysql,Macos,Perl,我对安装了mysql和apache的mac上的以下perl测试脚本有一个奇怪的问题: # stop all servers `mysql.server stop 2>&1`; `apachectl -k graceful-stop 2>&1`; is apache_is_running(), 0, 'determines if apache is not running'; `apachectl -k start 2>&1`; is apache_i

我对安装了mysql和apache的mac上的以下perl测试脚本有一个奇怪的问题:

# stop all servers
`mysql.server stop 2>&1`;
`apachectl -k graceful-stop 2>&1`;

is apache_is_running(), 0, 'determines if apache is not running';
`apachectl -k start 2>&1`;

is apache_is_running(), 1, 'determines apache is running';
is mysql_is_running(), 0, 'determines mysql is not running';

system "mysql.server start 2>&1";

is mysql_is_running(), 1, 'determines mysql is running';
print "hi\n";
exit;
当我使用
prove-l--verbose
运行测试时,我得到以下输出:

1..4
# Running my tests
ok 1 - determines if apache is not running
ok 2 - determines apache is running
ok 3 - determines mysql is not running
Starting MySQL
. SUCCESS!
ok 4 - determines mysql is running
hi

然后测试就挂起,永远不会完全退出。是最后一个命令导致了这种情况:
system“mysql.server start 2>&1”
我尝试过使用backticks而不是
system
,但没有效果。如果我取出最后一个命令,它将按预期正常退出。

好的,这是修复它的方法,但我仍然不清楚原因:

`mysql.server start >/dev/null 2>&1`;

好的,这是修复它的方法,但是我仍然不清楚为什么:

`mysql.server start >/dev/null 2>&1`;

有些软件包需要一些标准输入。尝试添加
以将标准输入设置为零。像这样吗<代码>系统“mysql.server start 2>&1我试过了,没有效果。我通常在标准输出和错误之前设置标准输入。我不记得这有什么区别。类似于:
system”mysql.server start&1
。我尝试了
system”mysql.server start&1“
和其他一些迭代,但运气不好。如果您运行的是linux/unix,则需要将其包含在
nohup
&
中才能真正在后台运行。如果这是您的情况,您可以尝试:
system“nohup mysql.server start 2>&1 log.file&“
。一些软件包需要一些标准输入。尝试添加
以将标准输入设置为零。像这样吗<代码>系统“mysql.server start 2>&1我试过了,没有效果。我通常在标准输出和错误之前设置标准输入。我不记得这有什么区别。类似于:
system”mysql.server start&1
。我尝试了
system”mysql.server start&1“
和其他一些迭代,但运气不好。如果您运行的是linux/unix,则需要将其包含在
nohup
&
中才能真正在后台运行。如果这是您的情况,您可以尝试:
system“nohup mysql.server start 2>&1 log.file&“