From Bash Script to Python?

V

Videodrome

Guest
I've decided I should learn a programming language if I want to pursue a longterm goal of a career in IT Security. Python seems popular with Kali Linux users.

In the thread title, I want to emphasize I have exposure to the Bash Shell. Mostly from my Linux college class. I'm very rusty on "real" programming with If/Then, While, or other programming statements from lack of regular use, but I think Programming Logic would come back to me. Mostly, I use Bash to just make long scripts of commands.

With that, I'd say I feel comfortable in the command line and I guess I can launch Python that way. However, I've seen IDEs mentioned like Idle or Eric for use with Python. It's not clear to me if this is an essential part of programming with Python, or just a option give you flexibility.

When I do Bash Scripts, I start a file with Nano and the line #!/bin/bash. I wondered if you just do something similar or just name something like FILE.py.

I guess I'm interested in recommendations on learning CLI-centric Python. If I want to do security work in Kali Linux with a programming edge, it seems like CLI would be a faster more flexible way to go.
 


The biggest difference is the use of a compiler of some kind to compile source code. In the case of Python it uses a just-in-time compiler allowing you to either use the built in Python environment (similar to node.js or bash). Every line is executed after you type it. I found the Python environment to be a great way to initially learn because it allowed me to try quick commands without having to recompile a file each time, but your code isn't saved so both have advantages I guess. I'd begin by playing around with the Python environment.

Another good link is MIT's intro to programming course. It is offered over open courseware and the class is taught in Python. It will teach you the language as well as the basics of programming. It does get into some in-depth topics (its MIT after all) but its a really good course.
http://ocw.mit.edu/courses/electric...o-computer-science-and-programming-fall-2008/
Also, the two e-books under "Readings" are free and are pretty great Python tutorials. I'm going through one right now but I haven't used Python for a while only use Java and C at work. I still like using vi for C programming though :cool:
 
@Videodrome hopefully your Python programming is going well. I've actually tried to pad my knowledge recently and found two really good tutorials I thought I'd share for anyone interested:

http://interactivepython.org/courselib/static/thinkcspy/index.html
- Covers everything from the basics of programming up through the advanced stuff. The cool thing is there are built-in activecode examples you can write and "compile" right from the website.

http://interactivepython.org/courselib/static/diveintopython3/index.html
- A more "meat and potatoes" tutorial for those already familiar with programming basics (from other languages). Its also hailed as one of the best Python tutorials on the web. Mark Pilgrim also has a version for Python 2.6/2.7 I believe. He adds some humor to it also so its not so cut-and-dry. Its a shame Mark disappeared from the net a couple years ago similar to _why the lucky stiff.
 
I do all my programming in vim <3
vim is my xoxo.
Nano was my first love, but I was young, I did not know what love was.
To be fair love is probably too strong a word for the feeling I had for nano, twas a rather flittering excursion.
 
I do all my programming in vim <3
vim is my xoxo.
Nano was my first love, but I was young, I did not know what love was.
To be fair love is probably too strong a word for the feeling I had for nano, twas a rather flittering excursion.
I'd like to use VIM, but it's intimidating..... o_O
 
I'd like to use VIM, but it's intimidating..... o_O
Once you learn to use it, you'll realize it's very powerful. I used to stay as far away from it until I started taking a Linux class. I think it was my Linux teacher who got me out of my comfort zone. Now, I don't know where I'd be without it. Especially when I'm programming :).
 
Once you learn to use it, you'll realize it's very powerful. I used to stay as far away from it until I started taking a Linux class. I think it was my Linux teacher who got me out of my comfort zone. Now, I don't know where I'd be without it. Especially when I'm programming :).

I'd second that!
Vim has some amazing functionality and can make you much more productive. I find myself using Vim all the time nowadays - not just on the command line, I also use gvim as my default text editor in desktop sessions too.

Emacs is another editor with a very rich and powerful feature set (and a ton of plugins/extensions). Personally, I've tried getting to grips with Emacs many times, but I've never really managed to get on with it. Whereas Vim just 'clicked', it just resonates with me. But I do know of many people who prefer to use Emacs for.....Well....Pretty much everything!

For quick, simple editing tasks on the command-line, editors like nano or pico are fine. For creating new files - using cat, or echo - with output redirected to a file will suffice. But for any serious editing, it really is worth learning to use a fully featured editor like Vim or Emacs!
 
I, on the other hand am an emacs user I had/have a problem with the original CLI vi editor and went with emacs. I am not aware of anything vim can do that emacs can't.

As I have said to my students year ago when they asked me which editor they should use to write C. My response was that a programmers editor is about as personal as their underwear. I can't make that choice for them! ;^)

YOU have to try different editors and choose the one right for you, not what's right for someone else, be it vim, emacs, nano, notepad, edlin, or whatever! ;^)
 
I, on the other hand am an emacs user I had/have a problem with the original CLI vi editor and went with emacs. I am not aware of anything vim can do that emacs can't.

As I have said to my students year ago when they asked me which editor they should use to write C. My response was that a programmers editor is about as personal as their underwear. I can't make that choice for them! ;^)

YOU have to try different editors and choose the one right for you, not what's right for someone else, be it vim, emacs, nano, notepad, edlin, or whatever! ;^)
Exactly!
 
I'd second that!
Vim has some amazing functionality and can make you much more productive. I find myself using Vim all the time nowadays - not just on the command line, I also use gvim as my default text editor in desktop sessions too.

Emacs is another editor with a very rich and powerful feature set (and a ton of plugins/extensions). Personally, I've tried getting to grips with Emacs many times, but I've never really managed to get on with it. Whereas Vim just 'clicked', it just resonates with me. But I do know of many people who prefer to use Emacs for.....Well....Pretty much everything!

For quick, simple editing tasks on the command-line, editors like nano or pico are fine. For creating new files - using cat, or echo - with output redirected to a file will suffice. But for any serious editing, it really is worth learning to use a fully featured editor like Vim or Emacs!
I especially like the fact that Vim can have more than one file in the editor window (Ctrl+w, s or Ctrl+w, v to split horizontally or vertically respectively), although I hear that emacs can have separate windows that can be switched between. Unfortunately, Vim does not have this feature. However, there is a program called VILE (VI Like Emacs) that can use the multiple window feature (as well as keeping the same feel of vi). I haven't tried it personally, but I may eventually, as this feature sounds intriguing.

To be fair, I must give credit to @DevynCJohnson for providing this resource (otherwise I wouldn't have ever known it existed ;)).
 
Last edited:
I, on the other hand am an emacs user I had/have a problem with the original CLI vi editor and went with emacs. I am not aware of anything vim can do that emacs can't.

As I have said to my students year ago when they asked me which editor they should use to write C. My response was that a programmers editor is about as personal as their underwear. I can't make that choice for them! ;^)

YOU have to try different editors and choose the one right for you, not what's right for someone else, be it vim, emacs, nano, notepad, edlin, or whatever! ;^)
emacs...Blasphemy!! :p In the end what really matters is the code...not the editor.
 
Didn't some famous American in the revolution in the late 1700s say "Give me emacs or give me death!"? That's my take, anyhow.

I agree - editor choice is like politics or religion - everyone is right, and everyone will fight for their choice to the death. Whatever works for you.

I do a lot of Perl code - I write and debug directly in emacs. Once I got through the learning curve, I could not understand why I did not use it all along. I have emacs on my Linux and Windows workstations.

vi, however, is an acronym for Viral Infection. Maybe it's because I learned vi writing COBOL-75 where you needed the caps lock on. I lost most of my hair because of that. Since vim is the next generation of vi, I just don't bother. Why do I need a next generation of an infection? :D
 
Heh heh, my main problem with emacs is this:
iu

Which is how my hands feel after using Emacs for extended periods. Remembering all of the keyboard shortcuts - which I find really counter-intuitive in Emacs - is a feat in itself. Let alone physically pulling some of them off, heh heh! XD

I've given Emacs a fair chance over the years. And I do return to it from time to time. I can see why some people prefer it, because it is a really good editor with a lot of very powerful functionality available, both built-in and via plug-ins/extensions - I do know a few people who do virtually everything from inside Emacs. But I just can't seem to grok Emacs or remember all of those crazy shortcuts. I tend to spend more time looking through the help files than actually working in Emacs. But that's just me!

Inevitably, I just end up getting frustrated and going back to Vim!

Heh heh, and if Vi stands for "Viral Infection", Emacs must stand for "Emacs May Actually Cause Sprains", or perhaps "Emacs Might Actually Cripple Students", heh heh! XD
 
Actually, emacs stands for Eventually Mallocs All Computer Storage.

Now that we have gigabytes of memory available, not so much.
 
This thread is so far off-topic! Can we drop the emacs bashing here? It has nothing to do with the original topic, python. Thank you!

Again for the record, each person has a right to their choice of editors, the same as their right to choose which political candidate to support! I could, if I wanted to, thoroughly trash vi as well, but I choose not to. Please, no more responses to this thread.
 

Members online


Latest posts

Top