本文介绍了如何使用winscp自动将文件从远程服务器传输到本地系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我需要将多个文件从远程服务器传输到本地计算机。 我已安排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 = 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(); // 文件传输 流程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 onoption confirm offopen username@hostnamecd folderContainingFilesoption transfer binaryget /desiredFile.extension pathInLocalComputerexitWhen I am running the task, winscp window is opening but it is not logging in.Any help anyone?What I have tried:option batch onoption confirm offopen username@hostnamecd folderContainingFilesoption transfer binaryget /desiredFile.extension pathInLocalComputerexit 解决方案 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自动将文件从远程服务器传输到本地系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-15 03:24