1

I found scripts by a former admin who scripted quite nice things with Bash or Python. All his scripts are well formatted and equipped with a always similar looking "script header" or "code header", I would call it.

I wonder how he did this and if maybe there is a well known tool out there what inserts and automatically updates these sorts of "code headers".

Any ideas / hints ?

Here is an example of such a code header block. It's not Python only. It was found in many languages and Linux scripts:

#!/usr/bin/env python
# vim:fileencoding=utf-8
#
#   project-name
#   ~~~~~~~~~~~~~~
#
#   script description
#
#   * Intended to be run as a cron job.
#
#   Project title:      Back-Up Management
#
#   Project directory:  FileHost/project-name
#
#   Project documents:  xxxxx
#                       yyyyy
#                       zzzzz
#
#   Target OS:          Unix
#
#   Target interpreter: Python 2.5
#
#   File encoding:      UTF-8
#
#   2010-11-23  adminName     Created
#
#   2015-06-12  AdminName     CHANGE: some description
#
#   $Id: script-name.py 474 2010-12-10 12:16:36Z adminName $
#
0

From the last line with text:

$Id: script-name.py 474 2010-12-10 12:16:36Z adminName $

you can assume that these files were kept in Subversion (there is an explanation of the $Id$ keyword here). The older CVS would also use the $Id$ keyword, but that would expand the filename to script-name.py,v (as is done here).

The two entries before that could come from the revision history commit comments, although they look handcrafted as does the rest of the header.

I would search the machine for bash/python files that has a string like Project title: on a line that is not commented out. There is a good chance the former admin left his "tools" somewhere on the system.

  • Thanks Anthon, good hint. that leaded me to "svn" and a feature called "svn keyword substitution" svnbook.red-bean.com/en/1.7/… It was an miss-assumption of mine that the whole header might be automaticaly created. it seems , as you mentioned, that most of the header is hand-crafted and somehow manualy added to new scripts. but the last line ($Id) is automatically updated by the "svn" client tool, if enabled in the svn project/repo. So, Question is SOLVED. thanks and greets Axel – Axel Werner Jun 19 '15 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.