Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > script files with python (instead of tcsh/bash)?

Reply
Thread Tools

script files with python (instead of tcsh/bash)?

 
 
Esmail
Guest
Posts: n/a
 
      03-21-2009
Hello all,

I am wondering if anyone is using python to write script files?

Right now I have a bigg'ish bash/tcsh script that contain some grep/awk
command plus various files are processed and created, renamed and
moved to specific directories. I also write out some gnuplot scripts
that later get executed to generate .jpg images.

In any case, the scripts are starting to look pretty hairy and I was
wondering if it would make sense to re-write them in Python. I am not
sure how suitable it would be for this.

I've looked around the web w/o much luck for some examples but come
short. Any comments/suggestions?

Thanks,
Esmail

 
Reply With Quote
 
 
 
 
Aahz
Guest
Posts: n/a
 
      03-21-2009
In article <(E-Mail Removed)>,
Esmail <(E-Mail Removed)> wrote:
>
>I am wondering if anyone is using python to write script files?


These days, I always convert any even slightly complicated script to
Python.

>I've looked around the web w/o much luck for some examples but come
>short. Any comments/suggestions?


Not sure what you're looking for here -- many things you'd run an
external program for in scripting can be accomplished with Python library
calls, and for the rest, you can use the subprocess module (or os.system
if you have no acces to Python 2.4 or higher).
--
Aahz ((E-Mail Removed)) <*> http://www.pythoncraft.com/

"Programming language design is not a rational science. Most reasoning
about it is at best rationalization of gut feelings, and at worst plain
wrong." --GvR, python-ideas, 2009-3-1
 
Reply With Quote
 
 
 
 
Esmail
Guest
Posts: n/a
 
      03-21-2009
Aahz wrote:
> In article <(E-Mail Removed)>,
> Esmail <(E-Mail Removed)> wrote:
>> I am wondering if anyone is using python to write script files?

>
> These days, I always convert any even slightly complicated script to
> Python.


well .. that sounds encouraging ...

>> I've looked around the web w/o much luck for some examples but come
>> short. Any comments/suggestions?

>
> Not sure what you're looking for here -- many things you'd run an
> external program for in scripting can be accomplished with Python library
> calls, and for the rest, you can use the subprocess module (or os.system
> if you have no acces to Python 2.4 or higher).


I have access to 2.5 or more recent. I guess I was looking for some
example scripts in Python and perhaps the equivalent in bash/tsch to
show some of the equivalences. I am being impatient, I guess I need to
dig into the language/library documentation a bit more on my own.

Esmail

 
Reply With Quote
 
Aahz
Guest
Posts: n/a
 
      03-21-2009
In article <(E-Mail Removed)>,
Esmail <(E-Mail Removed)> wrote:
>Aahz wrote:
>> In article <(E-Mail Removed)>,
>> Esmail <(E-Mail Removed)> wrote:
>>>
>>> I've looked around the web w/o much luck for some examples but come
>>> short. Any comments/suggestions?

>>
>> Not sure what you're looking for here -- many things you'd run an
>> external program for in scripting can be accomplished with Python library
>> calls, and for the rest, you can use the subprocess module (or os.system
>> if you have no acces to Python 2.4 or higher).

>
>I have access to 2.5 or more recent. I guess I was looking for some
>example scripts in Python and perhaps the equivalent in bash/tsch to
>show some of the equivalences. I am being impatient, I guess I need to
>dig into the language/library documentation a bit more on my own.


If you post a sample script you're trying to convert, you may get some
responses that show how different people would write it in Python.
--
Aahz ((E-Mail Removed)) <*> http://www.pythoncraft.com/

"Programming language design is not a rational science. Most reasoning
about it is at best rationalization of gut feelings, and at worst plain
wrong." --GvR, python-ideas, 2009-3-1
 
Reply With Quote
 
Peter Pearson
Guest
Posts: n/a
 
      03-21-2009
On Sat, 21 Mar 2009 09:26:02 -0400, Esmail <(E-Mail Removed)> wrote:
>
> I am wondering if anyone is using python to write script files?


If it can be done in a few simple lines of shell script,
fine: make it a shell script. But if it's more complex than
that, Python is clearer. Just my two cents.

--
To email me, substitute nowhere->spamcop, invalid->net.
 
Reply With Quote
 
Esmail
Guest
Posts: n/a
 
      03-21-2009
Aahz wrote:
>
> If you post a sample script you're trying to convert, you may get some
> responses that show how different people would write it in Python.


That's a nice suggestion .. I may end up doing this after I do some
readings, just wanted to make sure this is not too outlandish of an
idea

Esmail

 
Reply With Quote
 
Esmail
Guest
Posts: n/a
 
      03-21-2009
Peter Pearson wrote:
> On Sat, 21 Mar 2009 09:26:02 -0400, Esmail <(E-Mail Removed)> wrote:
>> I am wondering if anyone is using python to write script files?

>
> If it can be done in a few simple lines of shell script,
> fine: make it a shell script. But if it's more complex than
> that, Python is clearer. Just my two cents.


Hi Peter,

Yes, I agree .. the complexity of the script(s) have evolved to the
stage that I was thinking moving to Python makes sense (if that's something
that Python is suitable for - which it appears it is

Cheers,
Esmail

 
Reply With Quote
 
Ned Deily
Guest
Posts: n/a
 
      03-21-2009
In article <gq2rjc$ji$(E-Mail Removed)>, Esmail <(E-Mail Removed)>
wrote:
> Aahz wrote:
> > In article <(E-Mail Removed)>,
> > Esmail <(E-Mail Removed)> wrote:
> >> I am wondering if anyone is using python to write script files?

> >
> > These days, I always convert any even slightly complicated script to
> > Python.

> well .. that sounds encouraging ...>
> >> I've looked around the web w/o much luck for some examples but come
> >> short. Any comments/suggestions?

> > Not sure what you're looking for here -- many things you'd run an
> > external program for in scripting can be accomplished with Python library
> > calls, and for the rest, you can use the subprocess module (or os.system
> > if you have no acces to Python 2.4 or higher).

> I have access to 2.5 or more recent. I guess I was looking for some
> example scripts in Python and perhaps the equivalent in bash/tsch to
> show some of the equivalences. I am being impatient, I guess I need to
> dig into the language/library documentation a bit more on my own.


Perhaps the recipe for Pyline might give you some ideas on how to write
python scripts that play well with other scripts.

<http://code.activestate.com/recipes/437932/>

--
Ned Deily,
http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
Esmail
Guest
Posts: n/a
 
      03-22-2009
Ned Deily wrote:
>
> Perhaps the recipe for Pyline might give you some ideas on how to write
> python scripts that play well with other scripts.
>
> <http://code.activestate.com/recipes/437932/>


ah .. very nice .. thanks!

 
Reply With Quote
 
Esmail
Guest
Posts: n/a
 
      03-22-2009
andrew cooke wrote:
> Esmail wrote:
>
> just a quick data point here -


<..>

> so you might be better spending the time improving your bash skills than
> doing what will be largely drudge work in a language you already know.


I'll have to think about it .. at this point I know both languages about
equally "well" .. (not really), but Python has more universal applicability,
so I thought this might be a good reason to hone my Python skills and come
up with something useful at the same time.

Thanks for the post, the more data points,the better.

Cheers,
Esmail
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing arguments to & executing, a python script on a remote machinefrom a python script on local machine ashish Python 4 09-20-2012 07:28 AM
Python as active script <script language=python> misterdi Python 0 07-28-2009 04:30 PM
How to Machine A python script execute Machine B python script? johnny Python 5 07-11-2007 01:03 PM
Executing a python script with arguments from a python script olaufr@gmail.com Python 3 12-13-2005 02:49 AM
executing a python script from another python script. sarmin kho Python 1 06-04-2004 01:12 PM



Advertisments