首页 \ 问答 \ 如何自动导出运行ruby脚本所需的oracle环境变量?(How to automatically export oracle environment variable required to run a ruby script?)

如何自动导出运行ruby脚本所需的oracle环境变量?(How to automatically export oracle environment variable required to run a ruby script?)

我的ruby脚本需要连接到Oracle数据库。 所以我需要在脚本运行之前正确地导出ORACLE_HOME和LD_LIBRARY_PATH。 有没有一种方法可以在不使用shell脚本的情况下导出这些env变量? 我试图把ENV ['ORACLE_HOME'] ='/ usr / local / oracle_client'放在脚本的第一行,它不起作用。 现在唯一可行的方法是编写一个shell脚本,在那里导出这些变量,然后在那里运行ruby。 shell脚本如下所示:

export ORACLE_HOME ='/ usr / local / oracle_client'export LD_LIBRARY_PATH ='/ usr / local / oracle_client / lib'ruby myscript.rb --options

这有点难看,因为用户必须进入shell脚本来更改选项。 我想知道是否有更好的方法来做到这一点。 所以用户可以在命令行中执行:ruby myscript.rb --options


My ruby script requires connection to an Oracle database. So I need to export ORACLE_HOME and LD_LIBRARY_PATH correctly before the script would run. Is there a way that I can export those env variables without using shell script? I tried to put ENV['ORACLE_HOME'] = '/usr/local/oracle_client' at the first line of the script and it doesn't work. Now the only way it would work is to write a shell script, where export those variables and then run ruby there. The shell script looks like:

export ORACLE_HOME='/usr/local/oracle_client' export LD_LIBRARY_PATH='/usr/local/oracle_client/lib' ruby myscript.rb --options

It's kinda ugly because user has to go inside the shell script to change options. I'm wondering whether there's a better way of doing it. So user can just do at command line: ruby myscript.rb --options


原文:https://stackoverflow.com/questions/1495035
更新时间:2023-10-03 21:10

最满意答案

你应该可以在“文档”前加上路由前缀,然后设置默认值:

 routes.MapRoute("DocumentView", 
                "Document/{controller}/{action}/{id}", 
                new { controller = "General", action="Index", id = ""  }
            );

记住你想要完全定义的路由! 当设定路线时。 不要让那些意外的路线通过:D

查看Scott Hanselman在MIX上的演示非常有趣,并且您会发现一些很棒的提示!

http://www.hanselman.com/blog/Mix09FirstHalfRollupAndSessionVideos.aspx


you should be able to just prefix the route with "Document" and then set the defaults like:

 routes.MapRoute("DocumentView", 
                "Document/{controller}/{action}/{id}", 
                new { controller = "General", action="Index", id = ""  }
            );

remember with routing you want to be completely defining! when setting out the route. dont let those unexpected routes through :D

Check out Scott Hanselman presentation at MIX very funny and your pick up some great tips!

http://www.hanselman.com/blog/Mix09FirstHalfRollupAndSessionVideos.aspx

相关问答

更多
  • ASP.NET MVC 5仅在ASP.NET 4.x上运行。 ASP.NET MVC 6仅在ASP.NET 5上运行(使用DNX)。 MVC版本不能在ASP.NET版本之间混合使用。 然而,ASP.NET MVC 5和ASP.NET MVC 6仍然非常相似,尽管它们肯定也有一些重大变化。 例如,尽管MVC 5和MVC 6之间的路由功能非常相似,但您注册路由的位置也不同。 查看音乐商店示例应用程序, 了解如何在ASP.NET MVC 6应用程序中注册路由 。 ASP.NET MVC 5 runs only o ...
  • 其他文件是.NET Framework SP1的一部分。 它们位于目录C:\ Program Files \ Reference Assemblies \ Microsoft \ Framework \ v3.5 \ 安装sp1时,它们也会与gac一起注册。 The other files are part of SP1 of the .NET Framework. They are in the directory C:\Program Files\Reference Assemblies\Microso ...
  • 路由不是ASP.NET MVC的一部分 - 它只是ASP.NET本身的一部分。 好消息是它适用于MVC 和 WebForms(ASPX文件)。 查看Phil Haack关于如何使其发挥作用的博客文章 。 您需要对应用程序进行的唯一更改是将一些配置项添加到web.config,然后在global.asax.cs中注册您的路由(如果您使用的是VB,则注册global.asax.vb)。 Routing is not part of ASP.NET MVC - it's just part of ASP.NET ...
  • 您可以在ASP.NET MVC之外使用ASP.NET路由。 这篇 MSDN文章解释了如何。 You can use ASP.NET Routing outside of ASP.NET MVC. This MSDN article explains how.
  • 你应该可以在“文档”前加上路由前缀,然后设置默认值: routes.MapRoute("DocumentView", "Document/{controller}/{action}/{id}", new { controller = "General", action="Index", id = "" } ); 记住你想要完全定义的路由! 当设定路线时。 不要让那些意外的路线通过:D 查看Scott Hanse ...
  • 我假设您正在寻找“共享主机”? 如果是这样,我可以从经验告诉您,从共享主机运行网站可能会成为一场噩梦,因为您只能对设置进行如此多的控制。 我使用了虚拟专用服务器(VPS),它可以让您完全控制虚拟服务器...(远程桌面,管理员权限等)。 我最终以1和1的速度购买了一台每月运行约30美元的Windows VPS,我对此非常满意(我有多个运行的MVC网站)。 如果这将是一个严肃的网站,我会考虑VPS超过共享主机。 希望这可以帮助! Ended up going with GoDaddy for now. Got ...
  • 通过在分部类上使用MetadataType属性,可以将xVal与LLBLGen或任何其他ORM生成的类一起使用。 例如,如果您有一个名为UserEntity的LLBL生成实体,您将创建一个分部类并使用MetadataType属性将其标记为: [MetadataType(typeof(UserEntityMetaData))] public partial class UserEntity { } 您将创建Meta类,您可以使用适当的属性标记属性,如下所示: public class UserEntityM ...
  • 是的,从ASP.NET 3.5 SP1开始,可以在System.Web.Routing中找到路由功能。 有关如何入门的信息,请参阅此MSDN页面 。 Yes, starting with ASP.NET 3.5 SP1 the routing capabilities are found in System.Web.Routing. See for example this MSDN page for info about how to get started.
  • form.serialize()是在jQuery中发布表单的正确方法。 在错误处理方面,你已经掌握了它的要点。 如果服务器返回失败的HTTP代码,jQuery将仅将请求视为失败。 如果你想确定一个“逻辑失败”,即你的应用程序以某种方式失败,并想要返回一个html / json响应,指出出错的地方(哪个会有一个有效的HTTP代码),那么你需要添加一个错误标志给你的响应,并在“成功”处理程序中检查它。 我一直很喜欢Ben Nadel的做法。 我之前也用一个非常详细的代码示例回答了类似的问题 。 在重构所有jQu ...
  • 存储在App_Data文件夹中的文件不能直接被客户端访问。 ASP.NET阻止访问它。 所以不需要为这个特殊文件夹添加任何忽略路由,你不能使用像这样的URL /App_Data/Uploads/foo.txt 。 如果你想从这个文件夹提供文件,你需要编写一个控制器动作将从物理位置读取文件并将其返回给客户端: public ActionResult Download(string id) { // use the id and read the corresponding file from it's ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)