zoukankan      html  css  js  c++  java
  • GruntJs之FTP上传文件

    因为项目需要,又试了一下Grunt的FTP插件:grunt-ftpscript。以下步骤是基于上一篇博文的配置环境的:http://blog.csdn.net/puncha/article/details/10442147


    (一)安装

    1. C:Grunt>npm install grunt-ftpscript --save-dev
    2. C:Grunt>npm install matchdep --save
    装matchdep是为了能够通过一句命令,加载所有的Grunt插件,在下面的代码里面就能看到。

    (二)代码:

    这里我没有直接执行task,而是随后通过命令行执行的。


    Gruntfile.js:

    module.exports = function (grunt) {
        grunt.initConfig({
            ftpscript: {
                main: {
                    options: {
                        host: 'shacng109wqrh',
                        port: 21,
                        passive: true
                    },
                    files: [
                        { expand: true, cwd: 'filesToCopy', src: ['*'], dest: '/filesCopied/' }
                    ]
                }
            },
        });
    
        require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
    };

    .ftppass: (因为我没设FTP密码,所以不能写password这个属性,不然会出现笨等待)

    {
      "shacng109wqrh" : {
        "username": "cer"
      }
    }

    (三)运行:

    C:Grunt>grunt ftpscript:main

    提示成功:

    Running "ftpscript:main" (ftpscript) task
    Connected to SHACNG109WQRH.ads.autodesk.com.
    220-FileZilla Server version 0.9.41 beta
    220-written by Tim Kosse (Tim.Kosse@gmx.de)
    >> 220 Please visit http://sourceforge.net/projects/filezilla/
    Interactive mode Off .
    Invalid command.
    >> 257 "/filesCopied" created successfully
    >> 226 Transfer OK
    ftp: 382 bytes sent in Seconds Kbytes/sec.
    0.00382000.00221 Goodbye
    
    Done, without errors.

    就这么简单~~~







  • 相关阅读:
    python 进程、线程、协程感悟
    elk部署心得
    虚拟安装centos后无法上网、DNS无法解析问题解决
    mysql测试题
    爬取lol皮肤
    ping使用
    第一篇技术博客
    PADS layout修改字符时发生严重错误退出问题
    PADS 快捷键
    电容知识整理
  • 原文地址:https://www.cnblogs.com/puncha/p/3876884.html
Copyright © 2011-2022 走看看