用Javascript来生成ftp脚本
昨天闲着没事,又因为工作需要,写了一个脚本,用来做ftp。
当然不是直接做ftp,而是产生一个ftp的脚本,供ftp命令使用。
程序也很简单,就是遍历一下本地目录,然后产生一堆ftp命令。
为了避免以后再做此类重复劳动,我记在这里。
----------------------------------------------------------
function matchDemo(strFolderName)
{
var s;
var re = /200\d{5}/ig;
s = strFolderName.match(re);
return(s);
}
function init()
{
strScript ="open 192.168.1.32 \n";
strScript+="user sybase 111111 \n";
strScript+="bin\n";
strScript+="prompt\n";
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);
相关新闻>>
- 发表评论
-
- 最新评论 更多>>