I have a django server, and I have to upload some data through scp. I have this view:
pathFile = '/home/user1/foo.json'
user = 'user1scp'
server = 'someserver.com'
pathServer = '/var/www/foo.json'
os.system("scp %s %s@%s:%s" % (pathFile, user, server, pathServer))
On the console window where the page is running (i.e. where I called the command 'runserver') I have this output shown:
[21/Jul/2016 18:55:12] "GET /someurl/upload HTTP/1.1" 301 0
foo.json 100% 609 0.6KB/s 00:00
I want to be able to manipulate that output, so I can notify the user that all the files (there are multiple files to upload) were upload correctly, or which were not.
I tried the solution in this answer How to capture stdout output from a Python function call? but it didn't work. I tried Popen and subprocess and had no results as well. Maybe I'm doing something wrong?