本文介绍了Titanium Desktop createProcess运行shell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Titanium的新手,正在尝试创建一个小测试。我在Mac上并尝试运行以下代码:

I'm new to Titanium and am trying to create a small test. I am on a Mac and trying to run the following code:

<a id="btn-file" href="#">Create File</a>

<script type="text/javascript">
    document.getElementById("btn-file").addEventListener("click", function() {
        var process = Titanium.Process.createProcess(
            ['touch', 'file.txt']
        );
    });
</script>

但是,不会创建file.txt。如何从Titanium Desktop运行终端命令?最后,我想点击btn-file并运行一个shell脚本。

However, file.txt is not created. How do I run a terminal command from Titanium Desktop? Eventually, I'd like to click btn-file and it runs a shell script.

谢谢!

推荐答案

您错过了对启动方法的调用。你创建了这个过程,但是没有做任何事情!

You're missing a call to the "launch" method. You create the process, but don't do anything with it!

<a id="btn-file" href="#">Create File</a>

<script type="text/javascript">
    document.getElementById("btn-file").addEventListener("click", function() {
        var process = Titanium.Process.createProcess(
            ['touch', 'file.txt']
        );
        process.launch();
    });
</script>

这篇关于Titanium Desktop createProcess运行shell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 02:01