在 NANT 脚本中使用 scp 部署到远程服务器
我正在尝试使用 Nant.Contrib 中的 scp 任务将文件复制到远程服务器。
我已使用以下代码来执行此操作:
<target name= "QADeploy"description="gthtyb" >
<loadtasks assembly="C:\nantcontrib-0.85\bin\NAnt.Contrib.Tasks.dll" />
<echo message="htyh"/>
<scp file="D:\SourceTest\redist.txt" server="\\10.4.30.19" user="xxx:uuuu">
</scp>
</target>
但我收到错误:scp 无法启动。系统找不到指定的文件。 代码如下: 然后我下载了 pscp.exe 并修改了代码,如下所示:
<target name= "QADeploy"
description="gthtyb" >
<loadtasks assembly="C:\nantcontrib-0.85\bin\NAnt.Contrib.Tasks.dll" />
<echo message="htyh"/>
<scp file="D:\SourceTest\redist.txt" server="\\10.4.30.19" user="xxx:uuuu" program="C:\pscp\pscp.exe">
</scp>
现在我收到以下错误:
[scp] ssh_init:host does not exit
外部程序失败:C:\pscp\pscp.exe
你可以帮忙什么是最好的使用 Nant 将文件复制到远程服务器的方法。我正在使用此代码将文件部署到远程服务器。
谢谢
I am trying to copy a file to a remote server using scp task in Nant.Contrib .
I have used the following code to do that:
<target name= "QADeploy"description="gthtyb" >
<loadtasks assembly="C:\nantcontrib-0.85\bin\NAnt.Contrib.Tasks.dll" />
<echo message="htyh"/>
<scp file="D:\SourceTest\redist.txt" server="\\10.4.30.19" user="xxx:uuuu">
</scp>
</target>
But I am getting an error: scp failed to start. The system cannot find the file specified.
The code is as follows:
Then I have downloaded pscp.exe and modified the code as below:
<target name= "QADeploy"
description="gthtyb" >
<loadtasks assembly="C:\nantcontrib-0.85\bin\NAnt.Contrib.Tasks.dll" />
<echo message="htyh"/>
<scp file="D:\SourceTest\redist.txt" server="\\10.4.30.19" user="xxx:uuuu" program="C:\pscp\pscp.exe">
</scp>
Now I am getting the following error:
[scp] ssh_init:host does not exist
External Program Failed:C:\pscp\pscp.exe
can u please help whats the best way to copy a file to a remote server using Nant. I am using this code to deploy files to a remote server.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不必在服务器 IP 后面添加两个反斜杠。
另请注意,如果没有“path”参数,默认目标文件夹为“~”。
更新:这是导致 pscp.exe 程序崩溃的用户名。从您的用户名中删除“:”或尝试使用其他用户名。
You don't have to put two backslashes behind the IP of your server.
Also note that without the "path" parameter, the default destination folder is "~".
Update: it is the username that is crashing the pscp.exe program. Remove the ":" from your username or try with a different one.
pscp 在 Windows 中解析路径的方式似乎有些奇怪。以下内容应该修复 ssh_init:host 不存在问题:
it seems like there is some weirdness on how pscp parses paths in windows. The following should fix ssh_init:host does not exist problem: