我有一个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。此外,我希望将此输出发送到另一个文件。请帮忙
答案 0 :(得分:2)
SystemUtil.Run "c:\abc\def\doFTP.bat"
或者如果您要将参数发送到您的bat文件,那么
SystemUtil.Run "c:\abc\def\doFTP.bat" , file1 &" "& file2
答案 1 :(得分: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 "~"
我已经测试了这段代码并且它很棒,如果您有任何问题,请再次发布。