Unix commands within Python code

K

Kory Wheatley

Hi all,

I've just started to learn Python and I have a
question.

What is the syntax to embed Unix commands, or call
other programs within a Python script?

for example I would like to use a system chmod unix
command in the python script:

chmod 666 /tmp/filename

or call another script

/home/mailman/bin/list_members facultynews
${DIR}facultynew

I would appreciate if someone can send me the syntax,
or if its even possible.

--
Kory Wheatley



__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
 
L

Larry Bates

Basic is os.system(), but there are also
several os.popen#() calls depending on if you
need to get output or set environment before
execution.

There are also many os. commands that can
do this without shelling out to the Unix
shell, in particular:

os.chmod(path, mode)


FYI,
Larry Bates
Syscon, Inc.
 
J

Jeremy Sanders

There are also many os. commands that can
do this without shelling out to the Unix
shell, in particular:

os.chmod(path, mode)

There's also the shutil module with some useful shell-like commands.

Jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top