<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nideaderedes &#187; subir ficheros</title>
	<atom:link href="http://nideaderedes.urlansoft.com/tag/subir-ficheros/feed/" rel="self" type="application/rss+xml" />
	<link>http://nideaderedes.urlansoft.com</link>
	<description>Un blog hecho por mí y para mí</description>
	<lastBuildDate>Thu, 10 Jun 2010 18:46:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Python: Subir archivos a un FTP</title>
		<link>http://nideaderedes.urlansoft.com/2008/09/03/python-subir-archivos-a-un-ftp/</link>
		<comments>http://nideaderedes.urlansoft.com/2008/09/03/python-subir-archivos-a-un-ftp/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 07:00:43 +0000</pubDate>
		<dc:creator>gorkau</dc:creator>
				<category><![CDATA[programacion]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ftp]]></category>
		<category><![CDATA[subir ficheros]]></category>

		<guid isPermaLink="false">http://nideaderedes.urlansoft.com/?p=458</guid>
		<description><![CDATA[En esta segunda entrega de Python os propongo un ejemplo que permite subir un fichero a un servidor FTP.

#!/usr/bin/env python
# -*- coding: cp1252 -*-
&#160;
import ftplib
import os
&#160;
# Datos FTP
ftp_servidor = 'ftp.servidor.com'
ftp_usuario  = 'miusuario'
ftp_clave    = 'miclave'
ftp_raiz     = '/public_html' # Carpeta del servidor donde queremos subir el fichero
&#160;
# Datos del [...]]]></description>
			<content:encoded><![CDATA[<p>En esta segunda entrega de Python os propongo un ejemplo que permite subir un fichero a un servidor FTP.</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #808080; font-style: italic;"># -*- coding: cp1252 -*-</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">ftplib</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Datos FTP</span>
ftp_servidor = <span style="color: #483d8b;">'ftp.servidor.com'</span>
ftp_usuario  = <span style="color: #483d8b;">'miusuario'</span>
ftp_clave    = <span style="color: #483d8b;">'miclave'</span>
ftp_raiz     = <span style="color: #483d8b;">'/public_html'</span> <span style="color: #808080; font-style: italic;"># Carpeta del servidor donde queremos subir el fichero</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Datos del fichero a subir</span>
fichero_origen = <span style="color: #483d8b;">'/home/gorka/mifichero.zip'</span> <span style="color: #808080; font-style: italic;"># Ruta al fichero que vamos a subir</span>
fichero_destino = <span style="color: #483d8b;">'mifichero.zip'</span> <span style="color: #808080; font-style: italic;"># Nombre que tendrá el fichero en el servidor</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Conectamos con el servidor</span>
<span style="color: #ff7700;font-weight:bold;">try</span>:
	s = <span style="color: #dc143c;">ftplib</span>.<span style="color: black;">FTP</span><span style="color: black;">&#40;</span>ftp_servidor, ftp_usuario, ftp_clave<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">try</span>:
		f = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>fichero_origen, <span style="color: #483d8b;">'rb'</span><span style="color: black;">&#41;</span>
		s.<span style="color: black;">cwd</span><span style="color: black;">&#40;</span>ftp_raiz<span style="color: black;">&#41;</span>
		s.<span style="color: black;">storbinary</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'STOR '</span> + fichero_destino, f<span style="color: black;">&#41;</span>
		f.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
		s.<span style="color: black;">quit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">except</span>:
		<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;No se ha podido encontrar el fichero &quot;</span> + fichero_origen
<span style="color: #ff7700;font-weight:bold;">except</span>:
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;No se ha podido conectar al servidor &quot;</span> + ftp_servidor</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://nideaderedes.urlansoft.com/2008/09/03/python-subir-archivos-a-un-ftp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
