Advertisement
Guest User

Untitled

a guest
Jul 14th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. def lambda_handler(event, context):
  2. import subprocess
  3.  
  4. # Define parameters
  5. user = 'myUser'
  6. password = 'myPass'
  7. host = 'my.endpoint.amazon.aws.com'
  8. name = 'myDB'
  9.  
  10. # Define MySQL dump bash command
  11. bashCommand = "mysqldump --user=%s --password=%s --host=%s %s > myFile.sql"
  12. % (user, password, host, name)
  13.  
  14. # Define subprocess
  15. process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE)
  16.  
  17. # Execute subprocess
  18. output = process.communicate()[0]
  19.  
  20. # End
  21. return 'myDb RDS MySQL dump completed!'
  22.  
  23. START RequestId: 0e7e0d6b-4a06-11e6-8a09-a39e1a6b858b Version: $LATEST
  24. [Errno 2] No such file or directory: OSError
  25. Traceback (most recent call last):
  26. File "/var/task/lambda_function.py", line 15, in lambda_handler
  27. process = subprocess.Popen(bashCommand.split(), stdout=subprocess.PIPE)
  28. File "/usr/lib64/python2.7/subprocess.py", line 710, in __init__
  29. errread, errwrite)
  30. File "/usr/lib64/python2.7/subprocess.py", line 1335, in _execute_child
  31. raise child_exception
  32. OSError: [Errno 2] No such file or directory
  33.  
  34. END RequestId: IDstuff
  35. REPORT RequestId: blahblahblah Duration: 2.26 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 16 MB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement