Erlang:从命令行调用erl -eval永远不会退出 [英] Erlang: invoking erl -eval from command line never exits

查看:1060
本文介绍了Erlang:从命令行调用erl -eval永远不会退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Erlang命令,我想通过 erl -eval (编译erlydtl模板,如 erlydtl页面)。

I have a simple Erlang command that I want to invoke via erl -eval (to compile erlydtl template, as described on erlydtl page).

当我从shell的交互方式工作正常,命令立即退出:

When I do it interactively from shell everything works fine and the command exits immediately:

erl -pa ebin deps\erlydtl\ebin Eshell V5.9.3.1  (abort with ^G) 
1> erlydtl:compile('templates/tictactoe.dtl',tictactoe_dtl,[{out_dir,'ebin'}]).
ok

但是当我尝试通过 erl - eval (我想从.bat文件中运行):

But when I try to do it via erl -eval (I want to run this from .bat file):

erl -pa ebin deps\erlydtl\ebin -noshell -eval erlydtl:compile('templates/tictactoe.dtl',tictactoe_dtl,[{out_dir,'ebin'}])

然后命令执行其作业(模板被编译),但它不会退出,我需要用ctrl + c手动杀死shell进程(我在Windows下工作) 。

Then the command does its job (template is compiled) but it doesn't exit and I need to kill the shell process manually with ctrl+c (I'm working under Windows).

我只想让命令编译模板并退出。可能是什么问题?

I just want the command to compile the template and exit. What may be the problem?

更新:

一个解决方案可能会附加exit()在命令结束时调用,但是最后我会得到以下结果:

One solution may be appending exit() invocation at the end of command, but then I end up with following:

erl -pa ebin deps\erlydtl\ebin -noshell -eval erlydtl:compile('templates/tictactoe.dtl',tictactoe_dtl,[{out_dir,'ebin'}]),exit(success).
{"init terminating in do_boot",success}

Crash dump was written to: erl_crash.dump
init terminating in do_boot (success)

错误信息非常刺激,所以我仍然不喜欢这个解决方案。

The error message is very irritating, so I still don't like this solution.

推荐答案

这应该是窍门

erl -noshell -eval 'c:ls()' -eval 'init:stop()'

你必须告诉vm关闭

这篇关于Erlang:从命令行调用erl -eval永远不会退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆