10年工作经验,专研网站运维。
全部博文(454)
分类: LINUX
2011-05-11 14:40:39
CuteFTP可以编写脚本完成自动上传,解放了上传人员,提高了效率,减少了漏传和误传的机会。
实现的步骤如下:
1、在桌面新建一个脚本文件 test.vbs
内容如下:
Dim objArgs, MySite, theFile, Fso, Line
Set objArgs = WScript.Arguments
'Create a connection object and assign it to the variable
Set MySite = CreateObject("CuteFTPPro.TEConnection")
' Now set each property for the site connection
' You can omit this section to use the default values, but you should at least specify the Host
'The default Protocol is FTP, however SFTP (SSH2), FTPS (SSL), HTTP, and HTTPS can also be used)
MySite.Protocol = "FTP"
MySite.Host = "192.168.0.244"
'following lines are optional since the default is anonymous if no login and password are defined
MySite.Login = "dahai"
MySite.Password = "dahai"
'if necessary, use the UseProxy method and ProxyInfo or SocksInfo properties to connect through a proxy server
MySite.UseProxy = "BOTH"
'now connect to the site (also called called implicitly when most remote methods are called)
MySite.Connect
'perform some logic to verify that the connection was made successfully
If (Not Cbool(MySite.IsConnected)) Then
MsgBox "Could not connect to: " & MySite.Host & "!"
Quit(1)
End If
'InputBox "please input file name"
uploadFile = InputBox("请输入文件名")
'upload special files and folders in provied files.
Set Fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile("D:\\cftp\\" & uploadFile, 1, False)
//需要上传的路径的文件,文件名叫1.txt,在这个文件中填入上传的路径,上传的时候有这个文件就覆盖,没有就上传。
Do While theFile.AtEndOfStream <> True
fileName = theFile.ReadLine
localPath = "D:\工作文件\development\" & fileName
////就在这个路径下,要传my120文件夹,就指到这个目录下就行了,不要指到my120目录,就是指向要传的目录的上一级目录即可。。。。。这个目录是要上传的目录
remotePath = filename
MySite.UploadAsync localPath, remotePath
Loop
theFile.Close
'Complete. Show the status of this transfer.
MsgBox "Task done, final status is '" + MySite.Status + "'"
MySite.Disconnect
MySite.Close
'End of sample script. You can save you script and then run it by either selecting it from the Tools > Run Script menu or by double clicking on the script file in Windows
保存退出:
绿色部分需要删除,蓝色部分需要修改。
在d盘新建文件夹cftp,再新建一个文件 1.txt,在文件里填入路径,这个路径是D:\工作文件\development\这个文件夹下的相对路径,而且是这个文件夹下有的路径,没有就上传不了,说回来,就是将这个路径下的文件上传到服务器上,服务器根据路径自动匹配。举例:my120/application/Bootstrap.php