|
| FreeBSD | InfoSec | Programming | Cats | Miscellaneous | |
|
|
||||||
| Python | Perl | Bourne | ||||
![]()
Python is a high-level, interpreted scripting language, much like Perl. I had the opportunity to learn and use this language after I finished graduate school, which was a good four years after I had started programming. This is somewhat unforunate, as Python is an excellent beginner's langauge. The white-space It is a very straight-forward langauge, and is easy to learn. There are several key advantages, including:
![]()
Here is the obligitory "Hello World" script:
aristotle10:26pm[1]> python - Eric
Python 2.1.1 (#1, Nov 22 2001, 19:20:19)
[GCC 2.95.3 [FreeBSD] 20010315 (release)] on freebsd4
Type "copyright", "credits" or "license" for more information.
>>> import sys
>>> username = sys.argv[1]
>>> print "Hello World, ", username, "!"
Hello World, Eric !
Several things are being exemplified here. The first is the
command-line intepreter. The above is an exact copy of a session I just threw
together in a terminal window. I simply opened aterm, typed python -
Eric to launch the Python interpreter. The "-" flag told Python to
stay in command-line mode, taking "Eric" as an argument,
rather than trying to execute some script named "Eric".
After entering the interpreter I imported the sys module, which
has a pre-defined list called argv. This list contains the program
name in element 0, and then all of the arguments passed to the script in the
remaining elements.
In that same line, I created a variable called
username and made it a reference to the value held by
sys.argv[1].
In the last line of the script, I told Python to print to STDOUT the string
"Hello World, ", username, "!". It then grabbed the value
referenced by username.
At this point, if you have any more questions about Python, or are interested in learning how to actually write Python scripts, you should probably go here. The Python website has lots of great documentation and an outstanding tutorial. If you're interested in the scripts I've written, just proceed to the next section.
![]()
Below you will find all of the scripts I've writen on my own time which are worth publishing to the world. For the record, they are all released under the GNU Public License. Please feel free to download my stuff, use it, take it apart and figure out how it works, add to it, change it, or just ignore it. Whatever you do, please don't hesitate to give me your feed back, but please be sure to abide by the GPL.
There will be more to come, soon (I hope!)
![]()