I have a PHP script which does the following
$command = '/usr/bin/python /srv/www/vhosts/someurl.com/html/SftpUpload.py ' .
$config::SFTP_SERVER . ' ' . $config::SFTP_USER . ' ' . $config::SFTP_PASSWORD . ' ' .
$downloadZip . ' ' . $config::UPLOAD_LOCATION.$extDetails;
exec($command, $retval);
print_r($retval);
So it essentially executes a Python file passing it certain parameters. The Python file looks like the following
import sys, paramiko
if len(sys.argv) < 5:
print "args missing"
sys.exit(1)
print 'Argument List:', str(sys.argv)
hostname = sys.argv[1]
username = sys.argv[2]
password = sys.argv[3]
localpath = sys.argv[4]
filepath = sys.argv[5]
port = 22
try:
transport = paramiko.Transport((host, port))
# Auth
transport.connect(username = username, password = password)
# Go!
sftp = paramiko.SFTPClient.from_transport(transport)
# Upload
sftp.put(localpath, filepath)
finally:
sftp.close()
transport.close()
So it is supposed to use the arguments to SFTP a file to a server. At the top, I print out the arguement list just to see what I am getting, and it looks something like this
Array
(
[0] => Argument List: ['/srv/www/vhosts/someurl.com/html/SftpUpload.py', 'SFTPHostUrl.com', 'someUsername', 'somePassword', 'http://localurl.com/thefile.zip', '/srv/www/vhosts/destinationurl.com/html/thefile.zip']
)
I have tried changing the argv numbers and added one to each one, incase the first argument is the Python file.
Anyways, the file seems to execute but nothing happens. Is there any way I can see some errors or something so I can find out what is wrong, because at the moment I am only seeing the arguement list.
Thanks