LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-13-2003, 02:27 AM   #1
Robert0380
LQ Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Rep: Reputation: 47
python, executing regular linux commands


how would i go about getting python to execute a command like "ls" (to list the files) or "ifconfig -a" to get information about the network interfaces.
In C there is the system() function, is there an equiv. in python? Did some googling but coudnt find it.
 
Old 06-13-2003, 11:13 PM   #2
Robert0380
LQ Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Original Poster
Rep: Reputation: 47
13 hits, no response, and i still cant find it either.
 
Old 06-14-2003, 03:52 AM   #3
Proud
Senior Member
 
Registered: Dec 2002
Location: England
Distribution: Used to use Mandrake/Mandriva
Posts: 2,794

Rep: Reputation: 116Reputation: 116
exec(command) ?
All types explained in Process Management from the online Modules Index. You have a copy on your pc when you install Python
 
Old 06-26-2003, 03:35 PM   #4
MArgRes
Member
 
Registered: Jun 2003
Distribution: Fedora Core 2
Posts: 37

Rep: Reputation: 15
It's been a while since you posted, so you've probably found your answer. But, just in case you haven't, here you go.

There are a few different ways to do it, depending on what you need. Check out the python documentation on their usage, etc. They are all from the os module:

os.system('<your command'>. It will just execute the command and return an exit status.

The os.exec* variants and the os.spawn* variants. Read about them here.

Hope that helps!!!
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Python - need help narrowing a regular expression rose_bud4201 Programming 2 10-30-2005 12:37 AM
Regular Expressions in Python indian Programming 7 09-14-2005 11:00 PM
executing shell commands in c++ true_atlantis Programming 2 10-01-2004 04:53 PM
Executing Linux commands in C programs--->please help dennyvm Programming 3 01-15-2004 10:51 AM
Executing commands on startup viciousfish Linux - General 5 06-28-2002 02:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration