【问题标题】:Eclipse Command Line PluginEclipse 命令行插件
【发布时间】:2010-12-11 04:16:19
【问题描述】:

我需要一个 Eclipse 插件在 Linux 下运行 shell 脚本。我有一个漂亮的 Rsync 脚本,我想要 Eclipse 中的一个按钮来激活它。

最好的解决方案是,如果在我保存 Stuff 时也激活了 Rsync shell 脚本,那么也许我可以添加一个脚本构建器或类似的东西。

有人对这两种解决方案都有线索吗?

【问题讨论】:

    标签: eclipse shell command-line build scripting


    【解决方案1】:

    您可以使用 eclipse external tools feature。用于运行 shell 脚本,放在位置字段 /bin/sh 中,参数应该是 shell 脚本本身。

    如果您想在保存时运行脚本,可以使用 Eclipse 的内部构建器。

    项目 -> 属性 -> 构建器 -> 新建... -> 程序

    请务必检查“构建选项”选项卡上的“清理后”、“自动构建期间”选项。

    【讨论】:

    • 非常感谢,Builders Feature 正是我想要的。我什至可以在控制台上显示 Rsync 脚本的输出。现在我的服务器总是与我的开发机器同步,再见 FTP
    • 找到一个新的答案... Netbeans ;D
    【解决方案2】:

    我现在正在使用 Netbeans!

    7.0 Beta 版具有出色的包含命令行带有公钥的 FTP / SFTP 支持并且非常适合 Linux 和 PHP

    我对改变犹豫不决,但现在我比 Eclipse 更喜欢它。我唯一想念的是我非常快速的 Rsync 脚本,但还有一点需要关心!

    # !/bin/sh
    
    #Important Notes:
    # 0) Requrirements: RSYNC and SSH support on your Machine (install cygwin under windows, all good OS should already have it)
    # 1) You have to configure your ssh so yout do not have to enter the Password and the Port for your Server
    # 2) You have to edit the Paths and directorys to fit your Environment
    # 3) You may be interested in changing some RSYNC Options
    # 4) You may want to add this Script as Eclipse Builder to be run on autosave, to always keep your Server in sync.
    

    如果有人想在 Eclipse 中使用它,这里是脚本。

    您只需在 Eclipse 中设置一些环境变量($USER 等)。在我找到 Netbeans 之前,它对我很有用。

    # Push: rsync [OPTION...] SRC... [USER@]HOST:DEST
    
    # Useful rsync Options
    # -v verbose
    # -q quiet, supress non-error Messages
    # -r recursive, recurse sub-directorys
    # -u update, skip files that are newer on the server
    # -E preserve Executability
    # --chmod=CHMOD directory permissions to be set
    # -z compress file data during transfer
    # --compress-level NUM explicitly set compression level
    # --skip-compress=LIST skip compressing files with suffix in list (for jpg, png)
    # --exclude=PATTERN (for svn and eclipse config files)
    # --port (maybe we want a weird port)
    # -h output numbers in a human readable format (that is always good)
    # --progress (may be interesting)
    # --password-file read daemon-access password from file
    # --bwlimit=KBPS bandwith limit
    # -t transfer the modification times with the files ... makes next transfer more effective
    # --delete delete files that do not exist on other side
    # -C cvs-exclude - exclude RCS   SCCS   CVS   CVS.adm   RCSLOG  cvslog.*  tags  TAGS .make.state .nse_depinfo *~ #* .#* ,* _$* *$ *.old  *.bak *.BAK  *.orig *.rej .del-* *.a *.olb *.o *.obj *.so *.exe *.Z *.elc *.ln core .svn/ .git/ .bzr/
    # --stats ... could be interesting
    
    TARGET_HOST="www.example.com"
    TARGET_DIR="/var/www/"
    TARGET_USER="root"
    
    SOURCE_DIR="/home/user/workspace/myeclipseproject/"
    
    #Make this Variable empty if you do not want nonexisting Files on the Server to be deleted
    #DELETE=" --delete"
    DELETE=""
    
    OPTIONS=" -r -u -E -z -h --progress -t --stats --chmod=a+rwx --exclude-from=exclude.txt --chmod=a+rwx "$DELETE
    
    COMMAND="$OPTIONS  $SOURCE_DIR $TARGET_USER@$TARGET_HOST:$TARGET_DIR"
    echo 'rsync '$COMMAND
    rsync  $COMMAND
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-22
      • 1970-01-01
      • 1970-01-01
      • 2021-06-10
      • 1970-01-01
      • 2014-07-19
      • 2016-04-29
      • 1970-01-01
      相关资源
      最近更新 更多