vbscript - Script Works on Win 7, Not on Server 2003 -
i have script rather simple, boots winscp , checks directory file starts "tsa". if file exists, exits, if not exist, transfers on new file.
its , running on windows 7 machine, created - when transfer on server [windows server 2003] never finds file.
my script:
var filepath = "../zfinance/tsa"; // session connect var session = "someplace@somewhere.com"; // path winscp.com var winscp = "c:\\program files\\winscp\\winscp.com"; var filesys = wscript.createobject("scripting.filesystemobject"); var shell = wscript.createobject("wscript.shell"); var logfilepath = filesys.getspecialfolder(2) + "\\" + filesys.gettempname() + ".xml"; var p = filepath.lastindexof('/'); var path = filepath.substring(0, p); var filename = filepath.substring(p + 1); var exec; // run winscp check file existence exec = shell.exec("\"" + winscp + "\" /log=\"" + logfilepath + "\""); exec.stdin.write( "option batch abort\n" + "open \"" + session + "\"\n" + "ls \"" + path + "\"\n" + "exit\n"); // wait until script finishes while (exec.status == 0) { wscript.sleep(100); wscript.echo(exec.stdout.readall()); } if (exec.exitcode != 0) { wscript.echo("error checking file existence"); wscript.quit(1); } // log file var logfile = filesys.getfile(logfilepath); if (logfile == null) { wscript.echo("cannot find log file"); wscript.quit(1); } // parse xml log file var doc = new activexobject("msxml2.domdocument"); doc.async = false; doc.load(logfilepath); doc.setproperty("selectionnamespaces", "xmlns:w='http://winscp.net/schema/session/1.0'"); doc.setproperty("selectionlanguage", "xpath"); var nodes = doc.selectnodes("//w:file/w:filename[starts-with(@value, '" + filename + "')]"); if (nodes.length > 0) { wscript.echo("file found"); wscript.quit(0); } else { wscript.echo("file not found"); wscript.quit(1); }
after investigation, think i've found piece of code not function properly:
// parse xml log file var doc = new activexobject("msxml2.domdocument.6.0"); doc.async = false; doc.load(logfilepath); doc.setproperty("selectionnamespaces", "xmlns:w='http://winscp.net/schema/session/1.0'");
the problem is, have no idea why. log file @ point should written on xml code, not happen.
thanks in advance help.
and answer is........... winscp on windows server 2003 way out of date. out of date log different 1 version next. updated , viola! problem solved. help.
Comments
Post a Comment