我是靠谱客的博主 魁梧朋友,最近开发中收集的这篇文章主要介绍用Javascript来生成ftp脚本的小例子,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

程序也很简单,就是遍历一下本地目录,然后产生一堆ftp命令。

复制代码 代码如下:

function matchDemo(strFolderName)

{

var s;

var re = /200d{5}/ig;

s = strFolderName.match(re);

return(s);

}

function init()

{

strScript ="open 192.168.1.32 n";

strScript+="user sybase 111111 n";

strScript+="binn";

strScript+="promptn";

strScript+="cd /hisdata/olddata n";

dicWhiteList = new ActiveXObject("Scripting.Dictionary");

dicWhiteList.add ("20051205_pihou", "");

dicWhiteList.add ("20051206_pihou", "");

dicWhiteList.add ("20060701_pihou", "");

}

function EnumSubFolder(oSubFolder)

{

var eFolders=new Enumerator(oSubFolder.SubFolders);

var s="";

if(eFolders.atEnd())

{

return s;

}

else

{

for (; !eFolders.atEnd(); eFolders.moveNext())

{

s+="lcd "";

s+=eFolders.item();

s+=""n";

s+="mput *.*n";

}

return s;

}

}

function checkList(strToBeChecked)

{

return !dicWhiteList.Exists(strToBeChecked);

}

var strScript,dicWhitList;

var sFolderPath="e:\";

var oFs=new ActiveXObject("Scripting.FileSystemObject");

init();

if (oFs.FolderExists(sFolderPath))

{

//WScript.Echo("valid folder");

var oFolders=oFs.GetFolder(sFolderPath);

var eFolders=new Enumerator(oFolders.SubFolders);

if(eFolders.atEnd())

{

strScript += "mkdir "";

strScript += oFs.GetBaseName(sFolderPath);

strScript += ""n";

}

else

{

for (; !eFolders.atEnd(); eFolders.moveNext())

{

strTargetFolderName=matchDemo(eFolders.item()+"");

if(strTargetFolderName==null || checkList(oFs.GetBaseName(eFolders.item())))

continue;

strTmpFolderName="""+oFs.GetBaseName(eFolders.item())+""";

strScript += "mkdir "

strScript += strTargetFolderName;

strScript += "n";

strScript += "cd ";

strScript += strTargetFolderName;

strScript += "n";

strScript += EnumSubFolder(eFolders.item());

strScript += "lcd "

strScript += eFolders.item();

strScript += "n";

strScript += "mput *.*n";

strScript += "cd  nlcd n";

}

}

strScript+="byen";

WScript.Echo(strScript);

}

else

{

WScript.Echo("Bad Folder Name");

}


最后

以上就是魁梧朋友为你收集整理的用Javascript来生成ftp脚本的小例子的全部内容,希望文章能够帮你解决用Javascript来生成ftp脚本的小例子所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(133)

评论列表共有 0 条评论

立即
投稿
返回
顶部