<?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>GimmeSoda &#187; Windows Command Line</title>
	<atom:link href="http://www.gimmesoda.com/category/programming/windows-command-line/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gimmesoda.com</link>
	<description>The Blog of a Programmer</description>
	<lastBuildDate>Sun, 29 Jan 2012 10:26:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Automating FTP</title>
		<link>http://www.gimmesoda.com/automating-ftp/</link>
		<comments>http://www.gimmesoda.com/automating-ftp/#comments</comments>
		<pubDate>Thu, 13 Jul 2006 06:53:00 +0000</pubDate>
		<dc:creator>JuanJose</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows Command Line]]></category>

		<guid isPermaLink="false">http://www.gimmesoda.com/?p=7</guid>
		<description><![CDATA[The Problem
I need to automate an FTP transaction. No big deal right? I need to automate my FTP transaction from inside a .net console program, then execute the same program with multiple instances that process each downloaded file.
Shell()I&#8217;m really loving this command. It&#8217;s nothing new really but  [...]]]></description>
			<content:encoded><![CDATA[<p><span style="font-weight: bold;">The Problem</span></p>
<p>I need to automate an FTP transaction. No big deal right? I need to automate my FTP transaction from inside a .net console program, then execute the same program with multiple instances that process each downloaded file.</p>
<p><span style="font-weight: bold;">Shell()</span><span style="font-weight: bold;">I&#8217;m really loving this command. It&#8217;s nothing new really but for some reason or another it tends not to be common knowledge. I suppose the land of DOS and those wonderful black and white (although sometimes colorful) programs has been left slowly behind by most newer developers.</span></p>
<p><span style="font-weight: bold;">The Answer</span></p>
<p>Technically I already told you the answer to my problem, but I didn&#8217;t exactly explain it in full. Here is the code, I&#8217;ll explain it more later.</p>
<blockquote><p>Shell(&#8220;ftp -s:ftp.script&#8221;)</p></blockquote>
<p>Isn&#8217;t that just great!? It turns out that the normal MS-DOS FTP command already has a basic scripting control in it. So using Shell() to execute ftp, which is in my system PATH, and passing the -s:filename argument into it the ftp. The program then opens your script and uses it to answer each of the prompts it would normally give. My FTP script is very simple and here is a copy.</p>
<blockquote><p>prompt<br />
open ftp.myserver.com<br />
USERNAME<br />
PASSWORD<br />
cd directory<br />
mget *.txt<br />
bye</p></blockquote>
<p>Here is a quick breakdown of the script.<br />
prompt: is an FTP program command which disables or enables the interactive prompt<br />
I want this disabled so that I can automatically overwrite files, and accept file downloads.<br />
open: standard open command, set the server IP or server name here<br />
USERNAME: the server always asks for a username &#8211; set it here by replacing USERNAME with the real username<br />
PASSWORD: replace it with your password<br />
Repeat your password<br />
cd: change directory &#8211; usage: cd /directory/to/work/in/<br />
mget: multiple get &#8211; wildcards can be used for filename and extension<br />
Example:<br />
the*developer.txt would match:<br />
thecrazydeveloper.txt, themaddeveloper.txt, and so on.<br />
*.txt matches all files with .txt in the filename<br />
*.* matches all files in the directory<br />
bye: logs you out of the server</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gimmesoda.com/automating-ftp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced

Served from: www.gimmesoda.com @ 2012-02-10 09:21:54 -->
