Python and Shell Commands

How do I code a shell script using python

Page 1 of 1

2 Replies - 1626 Views - Last Post: 17 November 2008 - 09:38 AM Rate Topic: -----

#1 allen875  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 16-November 08

Python and Shell Commands

Post icon  Posted 16 November 2008 - 05:15 PM

Hello,

I'm new to programming for starters, my project is I want to make a python script to auto install all my favorite apps for linux. I'm trying to start the learning process with something simple, I know how to write a shell script using bash to do this because that is pretty straight forward but I want to start learning python so I want to write those same scripts in python code.

I can't find any information as to what code to use to call the correct information such as...

<code>sudo apt-get install geany</code>

How do you write this in a python script to get it to call to the shell do execute it.

Thanks For Your Help.

Is This A Good Question/Topic? 0
  • +

Replies To: Python and Shell Commands

#2 Stutzbach  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 29
  • Joined: 06-July 08

Re: Python and Shell Commands

Posted 17 November 2008 - 09:20 AM

import os

os.system('sudo apt-get install geany')



Hope that helps,
Was This Post Helpful? 0
  • +
  • -

#3 allen875  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 16-November 08

Re: Python and Shell Commands

Posted 17 November 2008 - 09:38 AM

View PostStutzbach, on 17 Nov, 2008 - 08:20 AM, said:

import os

os.system('sudo apt-get install geany')



Hope that helps,


Works, Thanks for your help.

Let the fun begin :P
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1