如何使用winscp自动将文件从远程服务器传输到本地系统 [英] How can I automatically transfer files from remote server to local system using winscp
问题描述
我需要将多个文件从远程服务器传输到本地计算机。
我已安排winscp.exe参数/ console / script = D: \ sync.txt
sync.txt文件包含以下命令。
选项批次
选项确认关闭
打开用户名@ hostname
cd folderContainingFiles
选项传输二进制文件
get /desiredFile.extension pathInLocalComputer
退出
当我运行任务时,winscp窗口正在打开,但它没有登录。
有人帮忙吗?
我尝试过的事情:
<
选项批量确认关闭
打开用户名@ hostname
cd folderContainingFiles
选项传输二进制文件
get /desiredFile.extension pathInLocalComputer
exit
尝试Index ::支持论坛:: WinSCP [ ^ 。]
嘿,
我在运行时创建批处理文件然后打开cmd应用程序然后运行它。
这是我的代码,如果它可以帮助任何人:
// 创建批处理文件
StreamWriter sw = < span class =code-keyword> new StreamWriter( @ C:\\ file_transfer。蝙蝠跨度>);
sw.WriteLine( open username:password @ host);
sw.WriteLine( option transfer binary);
sw.WriteLine( cd / mainFolder / subFolder);
sw.WriteLine( get file.extension C:\\pathWhereYouWantToPutIt \\< /跨度>);
sw.WriteLine( get * .extension C:\\pathWhereYouWantToPutIt \\< /跨度>);
// 多个文件的第二个获取
sw.WriteLine( 退出);
sw.Close();
< span class =code-comment> // 文件传输
流程p = new Process();
p.StartInfo.FileName = cmd.exe;
p.StartInfo.WorkingDirectory = @ C:\\ Windows \\System32< /跨度>;
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p.StartInfo.UseShellExecute = false ;
p.StartInfo.RedirectStandardInput = true ;
p.StartInfo.RedirectStandardOutput = true ;
p.Start();
p.StandardInput.WriteLine( @ cd C:\\If-You -Want-TO-GO-TO-另一个-指南跨度>);
p.StandardInput.WriteLine( WinSCP.com / script = \C:\\ file_transfer.bat跨度>);
I need to transfer multiple files from a remote server to local machine.
I have then scheduled winscp.exe with argument "/console/script=D:\sync.txt"
sync.txt file contains the following commands.
option batch on
option confirm off
open username@hostname
cd folderContainingFiles
option transfer binary
get /desiredFile.extension pathInLocalComputer
exit
When I am running the task, winscp window is opening but it is not logging in.
Any help anyone?
What I have tried:
option batch on
option confirm off
open username@hostname
cd folderContainingFiles
option transfer binary
get /desiredFile.extension pathInLocalComputer
exit
Try at Index :: Support Forum :: WinSCP[^.]
Hey,
I did by creating batch file on the run and then opening cmd application and then running it.
Here is my code if it helps anyone:
//creating batch file StreamWriter sw = new StreamWriter(@"C:\\file_transfer.bat"); sw.WriteLine("open username:password@host"); sw.WriteLine("option transfer binary"); sw.WriteLine("cd /mainFolder/subFolder"); sw.WriteLine("get file.extension C:\\pathWhereYouWantToPutIt\\"); sw.WriteLine("get *.extension C:\\pathWhereYouWantToPutIt\\"); //second get for multiple files sw.WriteLine("exit"); sw.Close();
//file transfer Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.WorkingDirectory = @"C:\\Windows\\System32"; p.StartInfo.WindowStyle = ProcessWindowStyle.Normal; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.Start(); p.StandardInput.WriteLine(@"cd C:\\If-You-Want-To-Go-To-Another-Directory"); p.StandardInput.WriteLine("WinSCP.com /script=\"C:\\file_transfer.bat");
这篇关于如何使用winscp自动将文件从远程服务器传输到本地系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!