sponsor Vim development Vim logo Vim Book Ad

Download Vim Scripts as Cron Task : Similar as GetLatestVimScripts, but this bash script can run as a cron task

 script karma  Rating 49/15, Downloaded by 1606  Comments, bugs, improvements  Vim wiki

created by
Frank Sun
 
script type
utility
 
description
Here is a simple bash script with similar function as "GetLatestVimScripts" plugin (vimscript#642):

    (1) It will check whether a new version of local vim script are released, if it is available, automatically download it to assigned directory, otherwise, nothing will be done;
    (2) It will update version information of the downloaded files into the list file.

1. Why you need this script?
--------------------------------------
In fact, core algorithm of this script is same with "GetLatestVimScripts". But the "GetLatestVimScripts" need to be run under vim platform, if you want it to be executed by some scheduler (for instance "cron" or "at") in background, it will not work!

Try to launch a shell command as below:
                               $ ex +"GetLatestVimScripts" &
and what did you see? Yes, this background job cannot run, not even to run as a cron task.

So, if you are lazy to update your vim plugins manually, and need a program to execute it as a schedule, download and enjoy this script.

2. Usage
------------
This is a bash script:
                         $ ./downloadvimscripts [-o restore_dir] scripts_list_file

NOTE:
    (1) use option "-o"  to assign a directory to restore your vim scripts. If it is absent, vim scripts will be downloaded to the same directory of "scripts_list_file";
    (2) "scripts_list_file" has same format of "GetLatestVimScripts.dat";
    (3) it will check whether the restore_dir is writable before downloading.

3. Format of "scripts_list_file"
----------------------------------------
As mentioned above, "scripts_list_file" has same format as "GetLatestVimScripts.dat", it has three fields:
                                    ScriptID SourceID ScriptName.

where,
    (1) ScriptID: you'll see it on the top of your browser in its "Location:" box whenever you click on the script at http://vim.sf.net/;
    (2) SourceID: start it off with a "1"; this script will download the file and keep this entry updated automatically;
    (3) ScriptName: the name or title of the script (may have spaces, etc).

I've provided an example of "scripts_list_file" in zip package, please research and reconfigure it for yourself.

4. Dependency
---------------------
For portability, assure these programs are installed in your system:
    (1) bash (version >= 3.0)
    (2) grep
    (3) sed
    (4) awk
    (5) wget or curl
 
install details
Make it executable,  and create a crontab task to schedule it, for instance:
                                 $ crontab -e
then add a new item:
                                 0 20 1 * * path/to/downloadvimscripts -o restore_dir path/to/scripts_list
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
downloadvimscripts_bash.zip 1.5.6 2010-05-23 7.0 Frank Sun - FIXED improper regular express of sed
+ ADD dependency check function
downloadvimscripts_bash.zip 1.5.4 2009-04-25 7.0 Frank Sun + ADD: show message to tell user how many packages were downloaded if their new version were found.
- Fix BUG: make script run successfully even if it could not get source_id which caused by poor internet environment.
downloadvimscripts_bash.zip 1.5.3 2008-12-14 7.0 Frank Sun -Fix a stupid bug in main body.
downloadvimscripts.zip 1.5.2 2008-11-19 7.0 Frank Sun +ADD curl as optional download tool
downloadvimscripts_bash.zip 1.5 2008-11-15 7.0 Frank Sun Initial upload
ip used for rating: 3.239.52.235

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github