PDA

View Full Version : Interactive command line tutorial with python



raja
March 10th, 2007, 04:49 PM
Hello everyone,
Seeing some requests for an interactive command line tutorial (like the ruby online tutorial), I wrote this tutor with python. I am relatively new to python and would appreciate comments and advice. Please untar the files to your desktop and run cmd_tutor.py from the terminal. As you can see, cmd_tutor.py parses 'lessons' written in a standard format. So it is very easy to extend this by writing more lessons.
Thanks

Update March 2009 - A new version can be downloaded from google code (http://code.google.com/p/cmd-tutor/).

tkjacobsen
March 10th, 2007, 05:05 PM
Very nice idea.. Just make the break between showing words shorter.. It is very annoying, because it is slower than I read... (And english is not even my native language).

EDIT:
If you add
#!/usr/bin/env python
as the first line.. The file can be executed with ./cmd_tutor.py

raja
March 10th, 2007, 05:08 PM
Very nice idea.. Just make the break between showing words shorter.. It is very annoying, because it is slower than I read... (And english is not even my native language).

Thanks. I am planning to have an optional argument to have it go faster. Of course you can modify the sleep time in the function slowprint to make it faster.

tkjacobsen
March 10th, 2007, 05:21 PM
Thanks. I am planning to have an optional argument to have it go faster. Of course you can modify the sleep time in the function slowprint to make it faster.

I know, but the people who will use it don't.. But it is great if you just add it as a choice when starting the program.

raja
March 10th, 2007, 05:23 PM
I know, but the people who will use it don't.. But it is great if you just add it as a choice when starting the program.

Point well taken. Thanks again for taking the time.

enopepsoo
March 10th, 2007, 05:30 PM
I only did lesson 1 but it was pretty cool. I ended up typing quit and changing the sleep interval like you said though.:)

raja
April 6th, 2007, 01:54 PM
Update !

Here is the new version with the promised '-q' argument that will disable the slow printing. Also there are five brand new lessons. An install script is added so that the program can be installed and called up from the command line easily. More details here (http://reachbeyondgrasp.blogspot.com/2007/04/interactive-linux-command-line-tutorial.html).

Suggestions are welcome.

raja
April 8th, 2007, 06:23 PM
No triers yet ?

Mike'sHardLinux
April 8th, 2007, 09:44 PM
At first, I installed it:

sudo python install.py install

After I did that, cmd_tutor would give me errors. I was only able to run it as sudo. Is this a problem with my configuration or a bug in the install process?

I uninstalled it, and just run it from the src directory and it works fine that way.

I do like it better with the -q option.

raja
April 9th, 2007, 01:11 AM
Thanks Mike.
There was a problem with the file permissions. I have changed the install script and it will be OK now.

tahrawee
August 29th, 2007, 11:11 AM
hi all
Thank you raja for your effort,
I'm a new linux user and I haven't any idea about the command line instructions,
I read all replaies but I couldn't run the cmd_tutor
thus please if you can, send me the lines I should write in the terminal to run the your work.
also how to know if python is installed in my system and it's workable?

LaRoza
August 29th, 2007, 12:38 PM
http://www.mired.org/home/mwm/try_python/

pmasiar
August 29th, 2007, 12:58 PM
how to know if python is installed in my system and it's workable?

What is your system? Ubuntu? Windows? something else?

sacherjj
August 29th, 2007, 07:17 PM
I won't get a chance to check this out on Ubuntu until I get home. I'm trying the first version on my work laptop, with Windows Python, I get an error on the import of readline. "ImportError: No module named readline." Is that typically part of the Python package?

Edit: Looking at the new install for 0.3 looks like it is pretty Unix dependent. Not a problem. I'll take a look tonight in Ubuntu.

Vox754
August 29th, 2007, 07:37 PM
This is essentially the "install" file included in the tar package.



To install:

1. Extract cmd_tutor package
tar -xvfz cmd_tutor-0.3.tar.gz

2. Go to cmd_tutorial directory
cd cmd_tutor-0.3

3. Install it
sudo python install.py install

4. Later if you want to uninstall it:
sudo python install.py uninstall

5. To remove it manually, just delete /usr/bin/cmd_tutor and
/usr/share/cmd_tutor/

Once installed you can type "cmd_tutor" in the terminal to start it.
However installation is optional.
You can run the program from the directory directly after you extracted it.
Just enter the src directory and type "python cmd_tutor.py" from the terminal.
You will have to give the path to the lessons if you choose not to install (cmd_tutor-0.3/share/lessons).

Enjoy!


You already have Python installed if you use Ubuntu.

Now remember, this tutorial is written in python, but teaches to use the Unix shell (bash in general). It is intended for those beginners that want to learn to use the terminal.

If you are an experienced programmer you may write additional lessons on harder topics.

This tutorial is very small in size and with enough lessons I believe it could be included easily in future Linux distributions as a quick and fun introduction to the terminal. Having a Windows port would be ideal to those not yet using Linux. In its current state probably it may run under Cygwin.

raja
August 30th, 2007, 03:11 AM
Hello guys,
Thanks for the interest in the program.
I am sorry if it was not clear that this has to be run in the linux terminal for it to work because it is essentially a demo of the functions that are available in the terminal.
The project is now hosted at sourceforge and you can download it there (http://sourceforge.net/projects/cmd-tutor/), but I havent worked on it since there did not seem to be much interest in it.
Any feedback, suggestions or new lessons are welcome !

bgs100
January 15th, 2009, 02:08 AM
Cool! I'd like to try to make my own version writtn in shell script. Which I will start... now.

myromance123
January 15th, 2009, 03:13 AM
OH wow ! I did not know there was a program like this!

:P

Its dated from 2007!!!?

Woah~
A program like this should be in the repos and promoted xD

aszxcv
January 15th, 2009, 03:22 AM
heres a good one i found http://try-python.mired.org/

myromance123
January 15th, 2009, 04:42 AM
Oooo

Thats cool man :)
I didnt know there were such cool programs available :D

I still think raja's program should be in repos lol so when you dont have the net available you can still learn plus its portable :P

Thanks man, Ima take full advantage of try python ^.^

:lolflag:

raja
March 21st, 2009, 02:32 AM
Thanks everyone for their interest in the program. I have a new version available for download at googlecode (http://code.google.com/p/cmd-tutor). Any comments and suggestions are welcome.