1. ftp 方式上传下载,
服务器搭建ftp, 安装vsftpd
curl -T /home/cyx/logcat -u cyx:cyx ftp://192.168.1.200/
curl -O -u cyx:cyx ftp://192.168.1.200/logcat
2. http 方式上传下载
2.1 下载
curl http://192.168.1.200/file/server -o aaa
2.2 cgi 方式 上传
server端搭建http cgi 服务器
sudo apt-get install apache2 cd /etc/apache2/mods-enabled sudo ln -s ../mods-available/cgi.load sudo service apache2 reload sudo chmod +x /usr/lib/cgi-bin/upload.sh 参考https://code-maven.com/set-up-cgi-with-apache
server端 /usr/lib/cgi-bin/save_file.py
client端, curl -F "filename=@testfile" http://192.168.1.200/cgi-bin/save_file.py
Here is the script save_file.py to handle file upload −
#!/usr/bin/python import cgi, os import cgitb; cgitb.enable() form = cgi.FieldStorage() # Get filename here. fileitem = form['filename'] # Test if the file was uploaded if fileitem.filename: # strip leading path from file name to avoid # directory traversal attacks fn = os.path.basename(fileitem.filename) open('/tmp/' + fn, 'wb').write(fileitem.file.read()) message = 'The file "' + fn + '" was uploaded successfully' else: message = 'No file was uploaded' print """\ Content-Type: text/html\n <html> <body> <p>%s</p> </body> </html> """ % (message,)
python参考 https://www.tutorialspoint.com/python/python_cgi_programming.htm