如何自动导出运行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
最满意答案
你应该可以在“文档”前加上路由前缀,然后设置默认值:
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 ...
-
mvc 1.0和DLL位置(mvc 1.0 and DLL location)[2024-03-25]
其他文件是.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 url路由(asp.net mvc url routing)[2023-11-05]
路由不是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.
-
C#asp.net mvc 1.0路由(C# asp.net mvc 1.0 routing)[2020-01-18]
你应该可以在“文档”前加上路由前缀,然后设置默认值: 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 ...
-
如何使用ASP.NET MVC 1.0从文件系统直接提供文件?(How Do I Serve Files Direct From the FileSystem Using ASP.NET MVC 1.0?)[2023-04-06]
存储在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 ...