/ Published in: Groovy
http://mina.apache.org/ftpserver/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/env groovy // file: FtpSvr.groovy /* Laurence Toenjes Jan 12, 2013 Standalone Groovy ftp server script (no jars to download if Groovy is properly installed). The default user is guest with password of guest and the ftp home/base directory is the home folder of the account running this script. A root account is also created with the ftp home/base dir set to / and the password is root (for root to fully work you would obviously have to run it under an account with expanded file permissions). Optional command line args: arg0 defaults to port 8021. arg1 (ftp base dir) defaults to the home directory of the user running this script. */ // See http://mina.apache.org/ftpserver/ for more details. // for OS X/*nix // don't forget to do: chmod +x FtpServer.groovy // also run as sudo ./FtpSvr.groovy for when using a port number < 1024 @Grapes([ @Grab(group='org.apache.ftpserver', module='ftpserver-core', version='1.0.6') , @Grab(group='ch.qos.logback', module='logback-classic', version='1.0.9') ]) println "### ftp port : $port" println "### ftp homeDir: $homeDir" println '' // the basics // FtpServerFactory serverFactory = new FtpServerFactory(); // FtpServer server = serverFactory.createServer(); // server.start(); // setup users myusersPropsFile.createNewFile(); } userManagerFactory.setFile( myusersPropsFile ); UserManager um = userManagerFactory.createUserManager(); users << [ uid:'guest', pwd:'guest', home:homeDir ] users << [ uid:'root' , pwd:'root' , home:'/' ] user.setName( map.uid ); user.setPassword( map.pwd ); user.setHomeDirectory( map.home ); auths.add(auth); user.setAuthorities(auths); // gi user; // gi user.getAuthorities(); um.save(user); } serverFactory.setUserManager( um ); // set the port of the listener factory.setPort( port ); // replace the default listener serverFactory.addListener("default", factory.createListener()); // start the server FtpServer server = serverFactory.createServer(); // groovy.inspect.swingui.ObjectBrowser.inspect( server ); // groovy.inspect.swingui.ObjectBrowser.inspect( server.userManager ); // gi server.userManager.getAllUserNames() as List; } mo.go(args) } }
URL: http://mina.apache.org/ftpserver/