Skip to content

Instantly share code, notes, and snippets.

@viniroger
Created February 28, 2019 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viniroger/560eb31c6ea339c4599b605e412dd79c to your computer and use it in GitHub Desktop.
Save viniroger/560eb31c6ea339c4599b605e412dd79c to your computer and use it in GitHub Desktop.
Execute bash script using python
from subprocess import check_output
# List files using pattern and get most recent
bashCommand = ("ls -1t %s/saida/arquivos_clientes/cn*.txt | head -1" %path)
# Define file name as last string, striping by '/'
filename = str(check_output(bashCommand, shell=True).strip(), 'utf-8')
remoteFileName = filename.split('/')[-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment