在批处理模式下运行时提示输入 SAS ODBC 连接密码 [英] Prompting for SAS ODBC connection password when running in batch mode
问题描述
出于各种原因,我更喜欢尽可能以批处理模式运行我的 SAS 程序.出于安全原因,我希望 SAS 在与 Teredata 仓库建立 ODBC 连接时提示我输入密码.我可以同时拥有这两种东西吗?
For various reasons I prefer to run my SAS programs in batch mode as much a possible. And for security reasons I'd prefer to have SAS prompt me for a password whenever making and ODBC connection to a Teredata warehouse. Can I have both of these things at once?
以下代码在以交互方式从 SAS 运行时工作正常,但在批量运行时不会创建提示.
The following code works fine when run from SAS interactively, but won't create a prompt when run in batch.
proc sql;
connect to odbc (prompt);
quit;
有人知道有什么方法可以让这个工作吗?(此外,我正在寻找专门使用 connect
语句的解决方案;SAS/ACCESS libname
访问 Teradata 的方法对我不可用.)
Anyone know of a way make this work? (Also, I'm looking for a solution specifically using the connect
statement; SAS/ACCESS libname
methods of reaching the Teradata aren't available to me.)
推荐答案
我不确定是否可以让批处理程序提示您.但是,您可以通过使用 SYSPARM
将密码(或连接字符串的任何部分或整个字符串)作为您在运行批处理程序时传递给 SAS 的参数来解决该问题.
I'm not sure that it's possible to have a batch program prompt you. However, you could solve the problem by making the password (or any part of the connection string or the whole string) a parameter you pass to SAS when you run the batch program, using SYSPARM
.
然后就可以在执行程序的时候在命令行中输入密码了.您可以轻松地执行一些操作,例如在正常的运行 SAS 批处理"程序中包含%1"参数,或为此用例编写自定义参数.
Then you can type the password in the command line when you execute the program. You could easily do something like include a "%1" parameter in your normal "run SAS batch" program, or write a custom one for this use case.
如果您喜欢通过右键单击菜单运行来运行东西,您可以通过编写 VB 脚本或 Powershell 脚本(Windows)或 Unix 中的类似脚本来解决它,打开提示窗口(通过操作系统)获取参数,然后批量运行程序(然后将其添加到右键菜单中).
If you like to run things by right-click menu run, you could solve it by writing a VB Script or a Powershell script (Windows), or a similar script in Unix, that opens a prompt window (via the OS) to get the parameter, then runs the program in batch (and then add that to the right-click menu).
这篇关于在批处理模式下运行时提示输入 SAS ODBC 连接密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!