1

I wrote a python program for Kali Linux GONE 64 (Debian 7) . I wrote it so it would run the metasploit database with the commands below. The problem is that i opens all of these commands in different shells. I want to run them all one by one in one shell. How do i do this in python?

import os
os.system("service postgresql start")
os.system("wait")
os.system("service metasploit start")
os.system("wait")
os.system("armitage")
Sukrit Kalra
34.7k7 gold badges73 silver badges71 bronze badges
asked Jan 5, 2014 at 19:46
3
  • 4
    Why does this need to be a Python script? Just use a shell script to hold all of these commands. Commented Jan 5, 2014 at 19:49
  • What are you expecting wait to do? (It probably isn't what you think it does.) Commented Jan 5, 2014 at 20:09
  • I added 'wait' hoping that it would stop all the shells from popping up. Also because i wanted to write a python script to do it just for the sake of programming in python. Commented Jan 7, 2014 at 16:21

2 Answers 2

2
import subprocess
subprocess.call("service postgresql start ; wait ; service metasploit start ; wait ; armitagedate", shell=True)
answered Jan 5, 2014 at 20:05
Sign up to request clarification or add additional context in comments.

Comments

1

If you don't want putting this into a separate script file, open /bin/sh in a subprocess and feed these commands to its stdin, line by line. You can also pass any parameters this way, if properly quoted.

answered Jan 5, 2014 at 19:51

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.