【问题标题】:Powershell and FTP (again)Powershell 和 FTP(再次)
【发布时间】:2010-12-17 00:22:47
【问题描述】:

这甚至可能吗?请帮忙

我尝试使用以下 Powershell 技巧,而不是接受来自文件 (-s:filename) 的输入:

**$cmd = 
"OPEN server
username
password
binary
cd somedir
lcd someotherdir
mget *.dat
disconnect
quit"
function ftpCommand { ftp -i -n }
$cmd | ftpCommand**

Powershell ISE 只显示正在运行的脚本/选择,按 Ctrl + Break 停止。

【问题讨论】:

  • 管道不工作。如果这是 Unix,您将有机会使用命令 chat
  • 我尝试这样做的原因是没有包含用户名密码信息的文件。实现这一目标的最佳方法是什么?
  • @user114385:为什么不直接在临时文件中替换密码?
  • 我支持 zdan... 并且 Pascal 说您不能按照您在上面想要的方式在 PowerShell 中使用这种管道方法。您想搜索“powershell ftp”以查看是否有人使用 .NET 类将某些 FTP 脚本共享为函数或模块。

标签: powershell ftp


【解决方案1】:

您可以使用 PowerShell 选项来执行此任务,因为预制函数已经存在 Herehttp://powershell.com/cs/media/p/804.aspx

您只需要运行:

Get-FTPFile -Source "ftp://server/path" -Target "C:\temp" -UserName "Username" -Password "P@ssw0rd"

【讨论】:

    猜你喜欢
    • 2021-05-01
    • 1970-01-01
    • 2011-02-22
    • 2013-05-24
    • 2011-09-10
    • 1970-01-01
    • 1970-01-01
    • 2022-01-05
    • 1970-01-01
    相关资源
    最近更新 更多