Skip to content

Instantly share code, notes, and snippets.

@elhackerlibre
Created June 7, 2015 13:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save elhackerlibre/8af9cdad053e1dbe33ba to your computer and use it in GitHub Desktop.
script de informacion para linux practica
#-----------#
## Python: ##
#-----------#
#!/usr/bin/env python
import subprocess
def funcion_uname():
uname = "uname"
uname_arg = "-a"
print "Obteniendo informacion del sistema con el comando %s :\n" % uname -a
subprocess.call([uname, uname_arg])
def funcion_disco():
diskspace = "df"
diskspace_arg = "-h"
print "Obteniendo informacion del sistema con el comando %s :\n" % diskspace
subprocess.call([diskspace, diskspace_arg])
def main():
funcion_uname()
funcion_disco()
main()
@PabloLemos
Copy link

Hola!!

Parece que tienes un pequeño error sintáctico en la línea 12. Entiendo que quieres mostrar el comando que vas a ejecutar. Deberías hacer algo del estilo:

def funcion_uname():
    uname = "uname"
    uname_arg = " -a"
    print "Obteniendo informacion del sistema con el comando %s :\n" % (uname + uname_arg)
    subprocess.call([uname, uname_arg])

y si quieres hacer lo mismo con el comando df:

print "Obteniendo informacion del sistema con el comando %s :\n" % (diskspace + diskspace_arg)

Un saludo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment