Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with a simple script
#1
Hi

im really new to python so i wrote this script:

#!/usr/local/bin/python

service postgresql start
service postgresql restart
msfdb reinit


i gave it the right permissions:

oot@kali:~# chmod u+x start_msf.py

the problem is that when i try to execute it i get an error which i dont unserstad:

oot@kali:~# python start_msf.py
File "start_msf.py", line 3
service postgresql start


thanks a lot to all !
Reply
#2
someone? please?
Reply
#3
Sorry, but that not even looks like python... if I have to bet it looks like a bash script to launch services (like systemctl or the good old rc)

If you want to access to an existing SQL db, you can do it with the DB-API (see Python Wiki to choose a module to install) but I think you first need a few hours with the python tutorial or everything is going to sound really strange... or maybe you are following a tutorial and mixed the commands to start the DB service from the command line with the real python script.

To explain a little bit the error, it is saying that the line service postgresql start is not a valid python expression.
Reply
#4
thnks a lot !!
Reply
#5
killerrex is right, what you are trying to do is bash-scripting. and are trying to stop and start the database server running on you system.
If you want to access a database work with a python database package. There are different packages working best with different kinds of databases, take a look here:
https://www.fullstackpython.com/databases.html
Psycopg should do the trick for you
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple Python script, path not defined dubinaone 3 2,692 Nov-06-2021, 07:36 PM
Last Post: snippsat
  Need help creating a simple script Nonameface 12 4,526 Jul-14-2020, 02:10 PM
Last Post: BitPythoner
  Simple text to binary python script gmills13 2 2,809 Feb-04-2020, 08:44 PM
Last Post: snippsat
  Made a simple script for android (really simple) but it is not running anddontyoucomebacknomore 2 2,355 Mar-06-2019, 12:19 AM
Last Post: anddontyoucomebacknomore
  Simple script that seems to misbehave? Nwb 1 2,331 Jun-10-2018, 05:30 AM
Last Post: Nwb
  First time with Python.. need help with simple script shakir_abdul_ahad 7 5,443 May-06-2018, 09:28 AM
Last Post: killerrex
  Simple script writted by a dumb dude, myself mm14ag 2 2,740 Apr-28-2018, 11:48 AM
Last Post: mm14ag
  Need help with a simple AHK script Stabu 0 2,088 Feb-24-2018, 08:27 PM
Last Post: Stabu
  A simple script - looking for feedback glidecode 2 2,673 Feb-20-2018, 11:18 PM
Last Post: glidecode
  Phillips hue simple on script Kimzer 6 4,552 Jan-16-2018, 07:53 AM
Last Post: Kimzer

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020