Good luck guys, I have this code below for python 2.7:
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import sys
import os
if len(sys.argv) <= 3:
for comando in sys.argv[1:]:
shell = os.system(comando)
print comando
But when I go to the terminal type ls -la it will return the following:
┌─[backz]@[NoSafe]:~/hk/programacao/python/manipular_arquivos
└──> $ ./comando.py ls -la
arq.txt comando.py executar_comando.py grep.py os sys usando_argv.py
ls
sh: 0: -c requires an argument
-la
This is only if I type a complete command in the terminal as ls -la. If I type ls, pwd, id, and so on all commands, it returns me the result in a good one. Problem occurs for compound command. Searching for the internet I realized that it is something straight from the linux shell, it is not an error but a return in which it can not identify.
I would like the help from you or is there any other way to complete the process with compiled commands thanks.