主题:Ruby怎样传递参数给子进程(最简单的进程之间通信方法)
时间: 2020-08-27来源:ITEYE
前景提要
相关推荐: 只想与你深发展.. Step by Step-Turning Ruby Files into Java Classes python 与 ruby 之间的区别 Ruby怎样传递参数给子进程(最简单的进程之间通信方法) ruby的线程和进程 服务器之间的命令和数据传输的通信方式 分布式Ruby--杀手级Ruby应用(源于我的Ruby新书) 微服务:通信协议:Restful,RPC(Dubbo、Motan、gRPC)
推荐群组: Hello World 达人
更多相关推荐
Ruby
1.子进程main.rb
ENV["ttt"]="yanzilee9292" system 'ruby t.rb'  
2.子进程t.rb
puts ENV["ttt"]  
3.运行
ruby main.rb


这样控制台会打印出yanzilee9292






参考:  http://ruby.about.com/od/rubyfeatures/a/envvar.htm


Environment variables are variables passed to programs by the command line or the graphical shell. Though there are a number of environment variables that only affect the command line or graphical shell itself (such as PATH or HOME), there are also several that directly affect how Ruby scripts execute.


Accessing Environment Variables from Ruby
Ruby has direct access to environment variables via the ENV hash. Environment variables can be directly read or written to by using the index operator with a string argument. Note that writing to environment variables will only have an effect on child processes of the Ruby script. Other invocations of the script will not see the changes in environment variables.

科技资讯:

科技学院:

科技百科:

科技书籍:

网站大全:

软件大全:

热门排行