Home > Web Front-end > JS Tutorial > A small example of using Javascript to generate ftp script_javascript skills

A small example of using Javascript to generate ftp script_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:30:21
Original
1349 people have browsed it

The program is also very simple, it just traverses the local directory and then generates a bunch of ftp commands.

Copy code The code is as follows:

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");

}


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template