From Bash Script to Python?

Discussion in 'Command Line' started by Videodrome, Feb 8, 2014.

  1. Videodrome

    Videodrome Active Member

    Messages:
    159
    Likes Received:
    63
    Trophy Points:
    28
    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.
  2. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Messages:
    1,150
    Likes Received:
    980
    Trophy Points:
    113
    Haider92 likes this.
  3. ryanvade

    ryanvade Administrator Staff Member Staff Writer

    Messages:
    1,139
    Likes Received:
    385
    Trophy Points:
    83
  4. Videodrome

    Videodrome Active Member

    Messages:
    159
    Likes Received:
    63
    Trophy Points:
    28
    Cool. I think this aspect of programming is what I was trying to clarify. For example, whether I could do this on a CLI only system like Ubuntu Server.

    I had a boring class where I had to do MySQL in CLI only and it could import data from scripts made with Nano. Seems similar.
  5. MikeyD

    MikeyD Active Member

    Messages:
    219
    Likes Received:
    105
    Trophy Points:
    43
    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:
    DevynCJohnson likes this.
  6. MikeyD

    MikeyD Active Member

    Messages:
    219
    Likes Received:
    105
    Trophy Points:
    43
    @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.

Share This Page