Solved

Use Powershell script to ftp

Posted on 2016-09-26
10
56 Views
Last Modified: 2016-10-19
I have to FTP a  file on serverA  (c:\customer.txt)  to serverB  (c:\Customerb.txt )
The ftp server has an Ip of 22.22.22.22 username of test123 and password test123
I am looking into a powershell script to achieve this.  Inputs appreciated.
0
Comment
Question by:Nana Hemaa
  • 5
  • 4
10 Comments
 
LVL 23

Accepted Solution

by:
Erik Bjers earned 250 total points
ID: 41817140
Do you want a script to connect to the FTP server, what do you want to do after connecting?

Here is a site with some info on scripting this

http://www.thomasmaurer.ch/2010/11/powershell-ftp-upload-and-download/
0
 
LVL 68

Assisted Solution

by:Qlemo
Qlemo earned 250 total points
ID: 41817604
Using FTPWebRequest is one way to perform FTP up/downloads, but for simple cases you can still rely on the FTP commandline tool.
@"
open 22.22.22.22
user test123 test123
binary
put c:\customer.txt c:\Customerb.txt
"@ | ftp -n -i -v

Open in new window

0
 

Author Comment

by:Nana Hemaa
ID: 41823899
Where do I execute below commands from?

@"
open 22.22.22.22
user test123 test123
binary
put c:\customer.txt c:\Customerb.txt
"@ | ftp -n -i  -v
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 41823996
As requested, it is a PowerShell script.
0
 

Author Comment

by:Nana Hemaa
ID: 41824098
sorry ftp commandline tool confused me.  
I get "port command successful" filename invalid.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 68

Expert Comment

by:Qlemo
ID: 41824120
Run
  ftp -n -i  -v
and then paste line by line to locate which part causes the error.
0
 

Author Comment

by:Nana Hemaa
ID: 41824148
I do not understand what you want me do...Do you have a link where I can read and understand the  -n -1  -v or can you explain please ..
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 41824168
You just run
ftp -n -v -i

Open in new window

in a cmd or PowerShell prompt. That starts FTP without trying to connect and log in, and does not display a prompt.
Then you take each line of the commands above, one by one, i.e.
open 22.22.22.22

Open in new window

and so on. and paste them into the (silent) prompt, until you get the error you showed. Then tell us the line causing this.
This is required because I have no clue where the error results from, and cannot test as each FTP server behaves different.
0
 

Author Comment

by:Nana Hemaa
ID: 41824189
ok thanks will update
0
 

Author Closing Comment

by:Nana Hemaa
ID: 41850716
Could not use the solution.  Just wanted to close case
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
Synchronize a new Active Directory domain with an existing Office 365 tenant
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now