WinSCP赋予脚本批处理文件不执行 [英] WinSCP script not executing in batch file

查看:1186
本文介绍了WinSCP赋予脚本批处理文件不执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个完美的执行命令提示符脚本。
如果我直接复制并贴脚本命令窗口,然后它工作正常,但是当另存它像Windows批处理文件并运行它,它是挂。

I have a script that is executing perfectly on command prompt. If I copy and paste the script directly to the command window then it is working fine, but when save it like Windows batch file and run it it is hanging.

option batch abort
cd \program files\winscp\ 
winscp.com /command "open HennTest:Nate82@data.test.com" /privatekey=C:\HennTest\VCS\HennTest_key_putty.ppk
option confirm off
get /*.csv C:\HennTest\VCS\
close
exit

这是连接到服务器,但使用类似的批处理时,不执行 GET 语句,但是当我复制/直接粘贴工作正常。
我需要使用它像批,因为我要自动运行的脚本下载文件。

It is connecting to the server but not executing the get statement when using like batch but it is working correctly when I copy/paste it directly. I need to use it like batch since I want to automate the script to download the files.

推荐答案

您正在结合WinSCP赋予命令和Windows命令到一个文件中。这是行不通的。该批处理文件在通话停下来 winscp.com 并等待它完成。的WinSCP反之并不知道批处理文件甚至存在的,所以它不能从那里读其命令。

Your are combining WinSCP commands and Windows commands into one file. That cannot work. The batch file stops on a call to winscp.com and waits for it to finish. WinSCP on the contrary does not know that the batch file even exist, so it cannot read its commands from there.

本作品:

cd \program files\winscp\ 

winscp.com /command ^
    "open sftp://HennTest:Nate82@data.test.com -privatekey=C:\HennTest\VCS\HennTest_key_putty.ppk" ^
    "get /*.csv C:\HennTest\VCS\" ^
    "close" ^
    "exit"

它利用的WinSCP命令行开关 /命令 ,你可以用它来指定其命令行命令的WinSCP

It makes use of WinSCP command-line switch /command that you can use to specify WinSCP commands on its command-line.

请注意,我已经纠正了一些其他的错误:

Note that I've corrected few other mistakes:


  • 选项一批中止是WinSCP赋予命令,而不是Windows的命令,所以之前的WinSCP你不能执行它。无论如何,WinSCP赋予默认为一批最新版本中止 ,运行脚本或命令行指定的命令时。所以,你不需要命令都没有。

  • 命令行开关 / privatekey 不应与脚本组合。使用 -privatekey 开关href=\"http://winscp.net/eng/docs/scriptcommand_open\" rel=\"nofollow\"> 打开命令。

  • 选项确认关闭也默认了最新版本的WinSCP的。

  • 当WinSCP赋予默认为SFTP协议,它的建议明确提到了 SFTP:// preFIX中的会话网址反正。

  • The option batch abort is WinSCP command, not Windows command, so you cannot execute it before WinSCP. Anyway, the latest versions of WinSCP default to batch abort, when running commands specified in script or command-line. So you do not need the command at all.
  • The command-line switch /privatekey should not be combined with scripting. Use -privatekey switch of the open command.
  • The option confirm off is also default in the recent version of WinSCP.
  • While WinSCP defaults to SFTP protocol, it's advisable to explicitly mention the sftp:// prefix in a session URL anyway.

这篇关于WinSCP赋予脚本批处理文件不执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆