[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

File to ftp with a prompt for file name

Posted on 2012-09-11
10
Medium Priority
?
628 Views
Last Modified: 2012-09-13
Hello,

I was wondering if there can be an ftp script (batch file or vbscript) that runs and logs into a server, changes to a certain directory and then prompts the user for a file name to enter.  The file name that the user enters will be the file that gets copied (ftp) to their local machine.

Thank you.
0
Comment
Question by:cbones
  • 5
  • 5
10 Comments
 
LVL 59

Accepted Solution

by:
Bill Prew earned 2000 total points
ID: 38388719
Here's the basic idea of how to do this in a BAT script.  Let me know if it doesn't make sense, or you have questions.

@echo off
setlocal

REM Prompt user for file name
set /P File=Please enter filename to transfer:
if "%File%" EQU "" (
  echo ERROR - No filename specified.
  exit /b
)

REM FTP file
(
  echo open 10.x.x.x
  echo user username 
  echo password
  echo lcd c:\temp
  echo cd myfolder
  echo get %File%
  echo quit
) | ftp -n -i

Open in new window

~bp
0
 

Author Comment

by:cbones
ID: 38389070
I tried the above but it doesn't open an ftp session.
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 38389220
What did it display?
 
~bp
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:cbones
ID: 38389287
It asks for a file name to transfer:

"Please enter filename to transfer:test.doc"

c:\>open 172.168.1.10 'open is not recognized as an internal or external command,
operable program or batch file

c:\>user

It also returned a windows error that I attached to this post.
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 38389351
Are you sure you copied it and modified it correctly, I just tried it here and it seems to run the FTP program.

~bp
0
 

Author Comment

by:cbones
ID: 38390588
It doesn't work on my Windows 7 machine.  I tried it on a windows xp and it keeps prompting me for the password.  I have tried with the password in the file and without the password in the file.  I receive the message "invalid command" after typing in my password.
So it seems that it works on windows xp but I can't get past this message.
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 38392068
You may have to play around with the FTP subcommands a bit, depending on the FTP server that you you are connecting to.  Different FTP server implementation can require slightly different approaches to connecting and authenticating.

What FTP server software are you using on the host server?

~bp
0
 

Author Comment

by:cbones
ID: 38392508
I had to remove the password field in the bat file.  Once I removed the password field it now allows me to type in my password and transfers the file.  I am trying to get the password stored in the field.  It is a unix machine.

Thank you.
0
 

Author Comment

by:cbones
ID: 38392642
Any reason why this wouldn't work from a Windows 7 machine?
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 38393310
No reason it shouldn't work on win7.

Try removing the word "user" from the second line of the section we send to FTP, that might not be needed for you FTP server.

~bp
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

829 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