2

我有一个 ftp 批处理文件,如下所示:

open <server>
<user>
<Password>
bin
cd \Curr_QA_DataLoad
put C:\Users\niprakash\Documents\XYZ\7090\NitishaQTPTest.txt
bye

我必须从 QTP 运行这个批处理文件。我手动输入 ftp.exe -s: 来运行它。但这不适用于 QTP。我还希望将其输出发送到另一个文件。请帮忙

4

2 回答 2

2
SystemUtil.Run  "c:\abc\def\doFTP.bat"

或者如果你有参数要发送到你的 bat 文件,那么

SystemUtil.Run  "c:\abc\def\doFTP.bat" ,  file1 &"   "& file2 
于 2012-10-08T14:46:19.283 回答
1

您可能想尝试这样的事情,这是刚刚在 POC 期间发现的

'这是给SUB的,用FTP命令创建一个文本文件

Sub OpenTextFileTest
   Const ForReading = 1, ForWriting = 2, ForAppending = 8
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.OpenTextFile("C:\works\MISC\testfile.txt", ForWriting, True)
   f.Writeline "open your ftp ip"
   f.Writeline "tabc" 'Username
   f.Writeline "xyz" ' Password
   f.Writeline "lcd C:\Works\MISC\test" 'local working directory on your computer, test.txt to be sent to the ftp server
   f.WriteLine "cd ftp_folder"  ' your folder on the ftp location
   f.Writeline "send test.txt"
   f.writeline "disconnect"
   f.WriteLine "Close"
End Sub
OpenTextFileTest             'Calling the sub

Set app=CreateObject("Wscript.shell") '' Simple code to send keys to the command propmt, pretty simple
SystemUtil.run("cmd.exe")
app.sendkeys "cd C:\works\MISC"
app.sendkeys "~" 'its for enter key
app.SendKeys "ftp -s:testfile.txt"
app.SendKeys "~"
app.SendKeys "quit"
app.SendKeys "~"
app.SendKeys "exit"
app.SendKeys "~"

我已经测试了这段代码,它工作得很好,如果您有任何问题,请再次发布。

于 2013-05-09T08:36:49.923 回答