首頁 > web前端 > js教程 > 主體

用Javascript來產生ftp腳本的小範例_javascript技巧

WBOY
發布: 2016-05-16 17:30:21
原創
1274 人瀏覽過

程式也很簡單,就是遍歷一下本機目錄,然後產生一堆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");

}



相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板