sudo命令/调用Python我在Ruby中刚开始编程,我想知道你是否能像 运行命令“须藤蟒蛇XXX.py”如何运行红宝石
我试着用RubyPython工作,但没有成功,因为我不知道如何以及在哪里获取文件的路径。
有没有人有这方面的经验?
sudo命令/调用Python我在Ruby中刚开始编程,我想知道你是否能像 运行命令“须藤蟒蛇XXX.py”如何运行红宝石
我试着用RubyPython工作,但没有成功,因为我不知道如何以及在哪里获取文件的路径。
有没有人有这方面的经验?
尝试使用系统的方法,从内核模块
http://www.ruby-doc.org/core-2.0/Kernel.html#method-i-system
非常感谢你,一个问题: 被调用程序能否返回一个值? –
编辑:试试这个
command_output = `sudo python DIRECTORY`
p command_output
其中directory是要执行该脚本的完整路径。
有几种方法,每种都有自己的差异。
看看这个博客条目:http://alvinalexander.com/blog/post/ruby/how-execute-external-shell-command-expansion
# define your variable
dir='/tmp'
# execute your shell command
puts `ls #{dir}`
编辑:看看这个堆栈溢出问题: Running a shell command from Ruby: capturing the output while displaying the output?
用这种方法我能够返回一个值吗? –
尝试使用我添加的新链接 – holaSenor
我不认为是我的情况我有一个Python程序从DS18B20读取温度...我需要启动该程序并收回温度。 –
有什么理由以root运行是行不通的计划? – Sirupsen
以“root”身份运行程序并不好。你在使用什么操作系统? – holaSenor