如何将密码标准输入传递给PG_DUMP?
我正在创建流程以在C#中运行PG_DUMP.EXE
var processStartInfo = new ProcessStartInfo
{
Arguments = @"-U postgres -W -f D:\postgres\test123_dump.sql postgres",
CreateNoWindow = true,
FileName = @"C:\PostgreSQL\bin\pg_dump.exe",
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardInput = true
};
Process process = new Process() { StartInfo = processStartInfo, EnableRaisingEvents = true };
process.Start();
using( StreamWriter sw = process.StandardInput)
{
sw.WriteLine("123"); // test password
};
,它将运行PG_DUMP.EXE,它将显示提示传递密码,但是StreamWriter似乎由于某种原因不起作用。
I'm creating Process to run pg_dump.exe in C#
var processStartInfo = new ProcessStartInfo
{
Arguments = @"-U postgres -W -f D:\postgres\test123_dump.sql postgres",
CreateNoWindow = true,
FileName = @"C:\PostgreSQL\bin\pg_dump.exe",
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardInput = true
};
Process process = new Process() { StartInfo = processStartInfo, EnableRaisingEvents = true };
process.Start();
using( StreamWriter sw = process.StandardInput)
{
sw.WriteLine("123"); // test password
};
It will run pg_dump.exe, it will show prompt to pass the password, but StreamWriter seems to not work for some reason.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用此字符串将您的身份验证信息直接放在参数列表中
You could use this string to put your authentication info directly in argument list