Note that there are some explanatory texts on larger screens.

plurals
  1. POPowershell: need to create an "active" ftp transfer connection from a PS script
    primarykey
    data
    text
    <p>I am using the following script file (ftp_test_2.ps1) to transfer files to an ftp server:</p> <pre><code>#we specify the directory where all files that we want to upload are contained $Dir="C:/Users/you-who/Documents/textfiles/" #ftp server $ftp = "ftp://192.168.100.101:21/" $user = "aP_RDB" $pass = "pw" $webclient = New-Object System.Net.WebClient $webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass) #list every txt file foreach($item in (dir $Dir "*.txt")) { "creating URI..." $uri = New-Object System.Uri($ftp+$item.Name) $uri "attempting upload... $item" $webclient.UploadFile($uri, $item.FullName) } </code></pre> <p>This works fine when the $ftp is set to the local host and also connecting to another ftp test server. However, on the production ftp server, the server rejects the upload with the Powershell error:</p> <pre><code>Exception calling "UploadFile" with "2" argument(s): "The remote server returned an error: 227 Entering Passive Mode (192,168,101,99,228,67)." At C:\Users\you-who\Documents\SandBox\ftp_test_2.ps1:17 char:24 \+$webclient.UploadFile &lt;&lt;&lt;&lt; ($uri, $item.FullName) \+CategoryInfo : NotSpecified: (:) [], MethodInvocationException \+ FullyQualifiedErrorId : DotNetMethodExceptionPP </code></pre> <p>On the production server there is a FileZilla server running. The messages in the server UI do not "seem" to show any errors:</p> <pre><code>(000029)2/5/2013 5:58:53 AM - (not logged in) (192.168.100.101)&gt; USER aP_RDB (000029)2/5/2013 5:58:53 AM - (not logged in) (192.168.100.101)&gt; 331 Password required for ap_rdb (000029)2/5/2013 5:58:53 AM - (not logged in) (192.168.100.101)&gt; PASS ******* (000029)2/5/2013 5:58:53 AM - ap_rdb (192.168.100.101)&gt; 230 Logged on (000029)2/5/2013 5:58:53 AM - ap_rdb (192.168.100.101)&gt; OPTS utf8 on (000029)2/5/2013 5:58:53 AM - ap_rdb (192.168.100.101)&gt; 200 UTF8 mode enabled (000029)2/5/2013 5:58:53 AM - ap_rdb (192.168.100.101)&gt; PWD (000029)2/5/2013 5:58:53 AM - ap_rdb (192.168.100.101)&gt; 257 "/" is current directory. (000029)2/5/2013 5:58:53 AM - ap_rdb (192.168.100.101)&gt; CWD / (000029)2/5/2013 5:58:53 AM - ap_rdb (192.168.100.101)&gt; 250 CWD successful. "/" is current directory. (000029)2/5/2013 5:58:53 AM - ap_rdb (192.168.100.101)&gt; TYPE I (000029)2/5/2013 5:58:53 AM - ap_rdb (192.168.100.101)&gt; 200 Type set to I (000029)2/5/2013 5:58:53 AM - ap_rdb (192.168.100.101)&gt; PASV (000029)2/5/2013 5:58:53 AM - ap_rdb (192.168.100.101)&gt; 227 Entering Passive Mode (192,168,101,99,228,74) (000029)2/5/2013 5:59:14 AM - ap_rdb (192.168.100.101)&gt; disconnected. </code></pre> <p>From my FileZilla ftp client on my laptop, I can connect and put/get files on the production ftp server <strong>IF</strong> I set the "transfer mode" to "active" (in the FileZilla client) for the connection to the production ftp server.</p> <p>Since I cannot change the production server, is there a way to set the transfer mode to "active" from within Powershell somewhere in my script above? I searched the web and MS sites for help on this, but could not find anything on . Any help greatly appreciated. </p> <p>-Dave Ef</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload