Shell callable from Python

This is a discussion on Shell callable from Python within the Linux Programming forums, part of the Platform Specific Boards category; First off I have very bad C/C++ abilities so take it easy and please comment any code you post. I'm ...

  1. #1
    Registered User ITAmember's Avatar
    Join Date
    Mar 2009
    Location
    Nebraska
    Posts
    72

    Arrow Shell callable from Python

    First off I have very bad C/C++ abilities so take it easy and please comment any code you post.

    I'm trying to create a BASH free version of Python that has all the capablities of BASH. So all I need is a C extension module that has some file execution and manipulation abilities. I would appreciate it if anyone could give me a list of features a shell scripting launguage needs or if someone would write some functions that did things like execute files or read/write files. However, if someone could give me some urls of websites that have source code examples or shell programming tutorial that would be even better.

    Thanks.

  2. #2
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    What exactly is a "BASH free version of Python" ? Python is... BASH free? The two are unrelated.

    If you're trying to write a scripting language, it's a little more involved that "a C extension module that has some file execution and manipulation abilities." You'll need to define the grammar of your language, write a parser, etc. Let alone write whatever functionality it might come with.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  3. #3
    Registered User ITAmember's Avatar
    Join Date
    Mar 2009
    Location
    Nebraska
    Posts
    72
    I should've stated the original question better, I am not trying to write a scripting laungauge, I'm trying to write a C extension module for Python. The question is how to write functions that execute files, read/write files, list all the files in a directory, check if the file/folder exists, etc. (bonus to anybody who can think up a full list) The reason I need this is because Python relies on BASH heavily to do a lot of file processing. (please don't ask why I don't want BASH, just take my word for it)

    Thanks for the quick response.

  4. #4
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Well there pretty much _are_ functions that execute, read and write files, etc... Since that kind of a thing depends on your system. they're supplied by your operating system, either as part of the standard library, or extensions thereof.

    Under linux, you execute files with exec(). You read and write files on any system with fopen, fgetc, fputc, fclose, etc... (all part of the standard library). And the list goes on. If you learn C, you'll learn how to do what you're talking about.

  5. #5
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    The reason I need this is because Python relies on BASH heavily to do a lot of file processing.
    I am almost certain that Python and Bash are in no way tied together - I use Python on Windows, which has no Bash. (None that Python knows about.)
    Quickly glacing at the Python source code, it would appear it does the IO directly. What makes you think it uses Bash?
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  6. #6
    Registered User ITAmember's Avatar
    Join Date
    Mar 2009
    Location
    Nebraska
    Posts
    72
    It only uses BASH on Linux, it uses the windows shell on windows. The os module is the part that uses BASH.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Language - When To Use What?
    By tjinr in forum A Brief History of Cprogramming.com
    Replies: 36
    Last Post: 08-06-2006, 02:04 AM
  2. What shell is more powerful?
    By xddxogm3 in forum Tech Board
    Replies: 10
    Last Post: 07-24-2004, 10:47 PM
  3. Python
    By Xterria in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 05-05-2002, 04:08 PM
  4. System.ini Shell Problems
    By (TNT) in forum Windows Programming
    Replies: 2
    Last Post: 08-26-2001, 01:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21