By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,675 Members | 2,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,675 IT Pros & Developers. It's quick & easy.

executing system calls

P: 3
Python Newbie running Mandriva Linux.

I want to do a system call from a python program. Mandriva has a package manager command called urpmi. If I wanted it to install a rpm I would say on the command line "urpmi rpmname". How can execute this command from my python program?

I found 'subprocess' in the python docs, imported it into IDLE, but I can't seem to make it's example work.

So, if I wanted to do the "urpmi rpmname" command or "urpmi --auto-update" which would update my system, what should the python statement look like in my python code?

Mar 25 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 849
Use os.system(). It takes a string input that is the same thing you would normally type on the command line to do something, for example, to do ls,
Expand|Select|Wrap|Line Numbers
  1. import os
  2. os.system('ls')
If those commands require root, as their equivalents do under Ubuntu, there's a bit more work needed, but it's still doable. I think.
Mar 25 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.