converting from shell script to python

William Park opengeometry at yahoo.ca
Tue Apr 1 01:37:59 EST 2003


Shao Zhang <shao at cia.com.au> wrote:
> Hi,
> 
> I need to convert a very simple shell script to python in order get it
> run on both windows and unix. However I cannot quite work out a simple
> way of doing it without using lists/array/join etc...
> 
> #!/bin/sh
> ROOTDIR=/usr/lib
> CLASSPATH="$ROOTDIR/a/a.jar:$ROOTDIR/b/b.jar:$ROOTDIR/c/c.jar"
> java -classpath $CLASSPATH foo
> 
> What is the most python way of doing the above?

Do what?  You are calling Java, and that would be OS issue, ie.
    os.system(...)
If you're talking about variable substitution, then 
    ROOTDIR = "/usr/lib"
    CLASSPATH = "%s/a/a.jar:%s/b/b.jar:%s/c/c.jar" % (ROOTDIR, ROOTDIR, ROOTDIR)
is one solution.  Though, why you don't want to use list/array/join
would be another topic.


> Will perl be a better
> choice for things like this?
> 
> Thanks.
> 
> Shao.

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
Linux solution for data management and processing. 




More information about the Python-list mailing list