我正在尝试使用 Atom 电子为 Mac 和 Windows 编写桌面应用程序.
I'm trying to use the Atom electron to write a Desktop App for both Mac and Windows.
我需要的是:
一个按钮.
当用户单击按钮时,它会运行以下 shell(或 python 脚本):
And when the user click the button it runs the following shell (or python script):
ping x.x.x.x
结果会显示在一个TextArea中.
And the result will be displayed in a TextArea.
我尝试使用 [shelljs] 和 [yargs],但它似乎不适用于 Atom electron.
I tried to use [shelljs] and [yargs] but it seems like it is not workable with Atom electron.
我想要的只是使用 JAVASCRIPT 编写桌面应用程序(当然是 GUI),它调用一些脚本(shell && python)来做一些自动化工作.
All I want is to use JAVASCRIPT to write Desktop App (with GUI of course) that calls some script (shell && python) to do some automation work.
任何建议将不胜感激,谢谢:)
Any suggestion will be appreciated, thanks :)
可以直接用Node做,可以使用child_process模块.请注意这是异步的.
It can be done directly with Node, you can use the child_process module. Please notice this is asynchronous.
const exec = require('child_process').exec;
function execute(command, callback) {
exec(command, (error, stdout, stderr) => {
callback(stdout);
});
};
// call the function
execute('ping -c 4 0.0.0.0', (output) => {
console.log(output);
});
我鼓励你也看看 npm,有大量的模块可以帮助你做你想做的事想要,无需调用 python 脚本.
I encourage you to also have a look at npm, there are tons of modules that could help you to do what you want, without calling a python script.
这篇关于如何从 Atom 电子应用程序中调用 Shell 脚本或 python 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
discord.js v12:我如何等待 DM 频道中的消息?discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 频道中的消息?)
如何让我的机器人提及发出该机器人命令的人how to make my bot mention the person who gave that bot command(如何让我的机器人提及发出该机器人命令的人)
如何修复必须使用导入来加载 ES 模块 discord.jsHow to fix Must use import to load ES Module discord.js(如何修复必须使用导入来加载 ES 模块 discord.js)
如何列出来自特定服务器的所有成员?How to list all members from a specific server?(如何列出来自特定服务器的所有成员?)
Discord bot:修复“找不到 FFMPEG"Discord bot: Fix ‘FFMPEG not found’(Discord bot:修复“找不到 FFMPEG)
使用 discord.js 加入 discord 服务器时的欢迎消息Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服务器时的欢迎消息)