(nodeA@foo.hyd.com)8> spawn(nodeA@bar.del.com, tut, test, [hello, 5]).
Run Code Online (Sandbox Code Playgroud)
我想在 bar.del.com 上生成一个进程,该进程没有对 foo.hyd.com 的文件系统访问权限(从我生成进程的位置),运行模块“tut”的子例程“test”。
有没有办法做到这一点,而无需为 nodeA@bar.del.com 提供已编译的“tut”模块文件?
我正在开发一个分散的Erlang应用程序.我目前正在使用单个PC并通过erl使用-sname标志初始化来创建多个节点.
当我spawn/4在其主节点上使用进程生成进程时,我可以看到io:format/2该进程中的调用在其主erl实例中生成的输出.
当我通过spawn/4组合使用远程生成进程时register_name,输出io:format/2有时会重定向回到进行erl远程spawn/4调用的实例,有时仍然完全不可见.
类似地,当我使用时rpc:call/4,io:format/2调用的输出被重定向回到进行erl`rpc:call/4'调用的实例.
如何获得将调试输出发送回其父erl实例的进程?
我开始使用Erlang和可以使用一个小的帮助申请时的PID从返回理解的不同结果spawn/3的process_info/1方法.
给定这个简单的代码,其中a/0导出函数,它只是调用b/0,等待消息:
-module(tester).
-export([a/0]).
a() ->
b().
b() ->
receive {Pid, test} ->
Pid ! alrighty_then
end.
Run Code Online (Sandbox Code Playgroud)
...请帮助我理解shell输出的不同原因:
例1:
在此,current_function的Pid被示出为tester:b/0:
Pid = spawn(tester, a, []).
process_info( Pid ).
> [{current_function,{tester,b,0}},
{initial_call,{tester,a,0}},
...
Run Code Online (Sandbox Code Playgroud)
例2:
在此,current_function的process_info/1被示出为tester:a/0:
process_info( spawn(tester, a, []) ).
> [{current_function,{tester,a,0}},
{initial_call,{tester,a,0}},
...
Run Code Online (Sandbox Code Playgroud)
例3:
在此,current_function的process_info/1被示出为tester:a/0,但current_function的Pid是tester:b/0:
process_info( Pid = …Run Code Online (Sandbox Code Playgroud) 我有一个与期望相关的问题.
当我运行包含以下行的abc.sh时
#!/usr/bin/expect
spawn scp /etc/httpd/conf/httpd.conf 192.168.0.12:/tmp
######################
expect {
-re "password:" {
exp_send "PASSWORD\r"
}
}
interact
Run Code Online (Sandbox Code Playgroud)
它的工作正常
但是当我在运行的脚本中使用类似的代码时,它不起作用
#!/bin/bash
clear
while read -u3 LINE
do
code .........
code .......
code ........
REMOTE_COMMANDS1="scp -r -v $BASE_DIRECTORY/$USERNAME $D_IPADDRESS:/home/"
spawn $REMOTE_COMMANDS1
######################
expect {
-re "password:" {
exp_send "redhat\r"
}
}
interact
done 3< /opt/sitelist.txt
Run Code Online (Sandbox Code Playgroud)
它给出了错误
./script.sh:line 62:意外令牌附近的语法错误}'
./script.sh: line 62:}'
我认为这是因为我没有在脚本的顶部包含#!/ usr/bin/expect但是如果我使用它并执行我的脚本它不会做任何事情并且在执行后显示终端中的所有代码.那么我们可以同时包括#!/ usr/bin/expect和#!/ bin/bash吗?
此致,Aditya
我是Erlang的新手,所以对于培训我尝试从头开始实现标准功能.我试图从列表模块创建map/2函数的并行实现.但我的实施工作非常缓慢.如果我在实施中犯了任何重大错误,你能指出我吗?

-module( my_pmap ).
-export([ pmap/2 ]).
-export([ map/4, collect/3 ]).
map( F, Value, Indx, SenderPid ) ->
SenderPid ! { Indx, F( Value ) }.
pmap( F, List ) ->
CollectorPid = spawn_link( my_pmap, collect, [ length( List ), [], self() ] ),
lists:foldl(
fun( X, Indx ) ->
spawn_link( my_pmap, map, [ F, X, Indx, CollectorPid ] ),
Indx + 1
end,
1,
List ),
Mapped =
receive
{ collected, M } …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个可以在后台执行mongodb服务器的简单脚本.目前我用的Process.spawn方法.它工作但我必须等待一段时间mongod才能完全运行(启动过程完成,数据库正在等待新的连接).
def run!
return if running?
FileUtils.mkdir_p(MONGODB_DBPATH)
command = "mongod --port #{port} --dbpath #{MONGODB_DBPATH} --nojournal"
log_file = File.open(File.expand_path("log/test_mongod.log"), "w+")
@pid = Process.spawn(command, out: log_file)
# TODO wait for the connection (waiting for connections on port xxxx)
sleep 2
yield port if block_given?
end
Run Code Online (Sandbox Code Playgroud)
以下是完整的脚本:https: //github.com/lucassus/mongo_browser/blob/master/spec/support/mongod.rb#L22
是否有可能sleep 2从这段代码中删除这个丑陋的任意?
我的第一个猜测是将管道连接到生成的进程并等待"等待端口xxxx上的连接"消息写入管道.但我不知道如何实现它.
我一直在尝试在cygwin上安装octopress.我用Google搜索但无济于事.我希望有人可以建议一个黑客(无论多么复杂)来解决这个问题.
我按照octopress安装说明进行操作.一切顺利,直到bundle install舞台.当我到达那一点时,安装退出并显示错误,告知它无法找到spawn.h.
我搜索并且显然spawn.h没有进入任何cygwin库.我从cygwin安装程序安装了所有c ++库,但这没有用.
你能帮忙解决这个问题吗?
我正在构建一个node.js应用程序并将其打包为二进制文件(使用nexe),并且如果有更新,则需要更新并重新启动该进程.当我生成新进程并退出时,我希望新进程接管终端,但这不会发生.这是我正在做的事情(使用child_process):
var spawn = require('child_process').spawn;
var child = spawn(process.execPath, process.argv, {
cwd: process.cwd(),
env: process.env,
detached: true,
stdio: 'inherit'
});
child.unref();
process.exit();
Run Code Online (Sandbox Code Playgroud)
子进程在终端上打印其所有控制台日志,但进入后台.我哪里错了?我正在使用OS X Mavericks.
我正在构建一个生成器,我最后需要npm install在我的应用程序中的某个目录中,我尝试过以下方法:
this.spawnCommandSync('cd', [this.destinationRoot() + '/my/folder'])
this.spawnCommandSync('npm', ['install'])
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
并且npm install不能在不同的目录中调用,也不能在任何yeoman安装mixins中调用.
我正在尝试使用外部包:
npm install [python-shell][1]
Run Code Online (Sandbox Code Playgroud)
现在,我只有基本的 js 文件和包附带的示例:
console.log('hey in main.js')
var PythonShell = require('python-shell');
PythonShell.run('./my_script.py', function (err) {
if (err) throw err;
console.log('finished running python script');
});
Run Code Online (Sandbox Code Playgroud)
随着my_script.py等
当我启动服务器时,console.log 说:
Uncaught TypeError: spawn is not a function
Run Code Online (Sandbox Code Playgroud)
在 python-shell 包的 index.js 中,正确需要 spawn(类似情况):
var spawn = require('child_process').spawn;
Run Code Online (Sandbox Code Playgroud)
后来,它在包中使用,如下所示:
this.childProcess = spawn(pythonPath, this.command, options);
Run Code Online (Sandbox Code Playgroud)
但是,spawn似乎确实是一个函数:
master$>node
> require('child_process')
{ ChildProcess:
{ [Function: ChildProcess]
super_:
{ [Function: EventEmitter]
EventEmitter: [Circular],
usingDomains: true,
defaultMaxListeners: 10,
init: [Function], …Run Code Online (Sandbox Code Playgroud)