Solved

Windows 2000: Need a quick ftp script please!

Posted on 2002-06-14
21
19,230 Views
Last Modified: 2013-12-13

Hi,

I have a Dell Pentium III laptop running Windows 2000.  It comes with a DOS version of FTP, plus I have Hummingbird Connectivity V7.0.0.0.0.

I want to write, or have someone tell me, a script for a simple ftp script:

  1. Login to a particular server, with a certain username and password.
  2. Upload files from my C drive to the network.
  3. Close the connection.

I don't mind how it is written: DOS or Hummingbird.  However, there are just two conditions:

1. Files transferred are in a directory which I would like to specify as the script is being run.  i.e., the directory name cannot be hard-coded.  

2. The destination directory matches the source directory name.  e.g., transfer from C:\mydirectory to <unix home directory>/mydirectory.

Many thanks in advance for your help.


Cheers,

Mark

P.S. Yes I know there is a script assistant called Hummingbird Basic but it doesn't seem to be working well because I don't have Visio installed (?).

0
Comment
Question by:Mark Ebden
21 Comments
 

Author Comment

by:Mark Ebden
Comment Utility

P.P.S. I want to stress that I don't care how it is written - any method is fine, as long as it runs! :)
0
 
LVL 1

Expert Comment

by:laax
Comment Utility
Type the following in your DOS Propmpt.

X Take a back up of your files before transfer. X

Step 0. Go to the source directory in your system.

Step 1. ftp <Server name>
    Enter username and password

Step 2. cd <to destination directory>
    Use cd command to go to your desired directory.

Step 3. put <your file>
    Use put to transfer file.  Use 'bin' or 'asc' depending
upon what data you want to transfer...'bin' for Binary and
'asc' for Ascii.  Finally check the number of bytes at both end if possible.
    [use get command to get files from destination]

Step 4. bye
     Now you will be back in DOS prompt.
0
 

Author Comment

by:Mark Ebden
Comment Utility

Thank you, but I was looking for a script.  In other words, I need this process automated owing to its frequent use.  Sorry if I wasn't clear.
0
 
LVL 1

Expert Comment

by:laax
Comment Utility
Hi,

   You can write the ftp commands in a text file and
pass it as an argument to ftp application.
Ex.  c:\> ftp -s:<script file name>

   You can also write the about command in a batch file
and use it from explorer, desktop and/or start menu.
Ex.  MyUpload.bat contains the following line.
     // If you don't want to see the output of ftp app.
     // use 'echo off'
     // echo off
     ftp -s:<script file name>

Laax.
0
 

Author Comment

by:Mark Ebden
Comment Utility

Thank you!  We're almost there.  Any ideas on how to implement the two 'conditions' in the question above?

Cheers,

Mark
0
 
LVL 1

Expert Comment

by:laax
Comment Utility
Create Main.bat as shown below.
This batch file dynamically creates the ftp script file.
Pass the directory name to Main.bat file as an argument.
Alter Main.bat in the way you want to creat your script file.

Note:
1. At the end of Main.bat you can see 'Call OldBatch.bat'
replace OldBatch with the batch file name that calls the
ftp with -s option.

2. Otherwise replace 'call OldBatch.bat' with "ftp -s:myscript.txt" directly. (In this case remove 'echo ftp  > myscript.txt' from Main.bat and change '>>' with '>' in the next line.


-----------------------------------------------------
Main.bat
-----------------------------------------------------
@echo off
echo Main running
REM single > is to create new file
REM and ">>" is to append to file
echo ftp  > myscript.txt
echo open yourSiteName  >> myscript.txt
echo username  >> myscript.txt
echo password  >> myscript.txt
echo cd %1 >> myscript.txt
echo lcd %1 >> myscript.txt
echo put FileToTransfer.zip >> myscript.txt
echo bye >> myscript.txt
call OldBatch.bat
REM Otherwise use ftp -v -s:myscript.txt
echo Main ending
-----------------------------------------------------

If you call Main.bat with 'MyDir' as argument from C:\>
the script will look something like this.
-----------
ftp
open Server
username
password
cd MyDir
lcd MyDir
put FilesToTransfer
bye
------------
i.e attempting to transfer files from C:\MyDir to <UnixHome>\MyDir.

  Hope it is clear.  Please write to me if you have any
doubts.

Laax.
0
 

Author Comment

by:Mark Ebden
Comment Utility


Thanks!  We are 98% there now.  I am transferring MULTIPLE files, i.e. *.* will do.  How can I automate that?  mput still requires user input.  (Pressing 'y' to confirm each transfer.)


=--=Mark
0
 
LVL 1

Expert Comment

by:laax
Comment Utility
use -i switch for ftp.
C:\> ftp -i -s:<filename>

 -i suppresses interactive prompting during multiple file transfers.
;-)
Laax
0
 

Author Comment

by:Mark Ebden
Comment Utility

Hi,

Ok, I tried out the script now.  However, it won't let me log in.  After the 'open' command, everything collapses.

Here's what I see on the screen:
  Transfer running
  ftp> open robots.ox.ac.uk
  User (robots.ox.ac.uk:(none)):

  Login incorrect.
  Login failed
  ftp>
  Invalid command.
  ftp> cd 3177
  Please login with USER and PASS
  (...and so on)


Any ideas?

Thanks,

--Mark
0
 
LVL 1

Expert Comment

by:laax
Comment Utility
The username and/or password is wrong.  Please check the values in the script file.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:Mark Ebden
Comment Utility

I should have mentioned, I edited the script and then triple-checked that I had the correct spellings for my own username and password.  Have you tried this script yourself?  Thank you again,

Mark

0
 
LVL 1

Expert Comment

by:laax
Comment Utility
Are you able to manually login to the ftp server using those username and password?
try...
C:\> ftp <server>
<enter username and password when asked>
dir -- confirm that you could see the files at current directory(Unix..)

I hope you are not using your windows username and password.

Laax.
0
 

Author Comment

by:Mark Ebden
Comment Utility

Yes, I can.  The script works if I do effectively the same thing manually.  Are you able to successfully run such a script yourself?  I'm using Windows 2000 and DOS 5.00.something.


Cheers,

Mark
0
 
LVL 1

Expert Comment

by:laax
Comment Utility
Okay....Remove -i switch of ftp application.
Instead, use 'prompt' in the script before 'mput' command.

prompt turns on/off the interactive mode...by default it is on....so..calling 'prompt' switch off the interactive mode.
0
 

Author Comment

by:Mark Ebden
Comment Utility

Thank you, I will try that during the week when I get a chance.  I'll let you know but it might take a few days.


Cheers,

Mark
0
 
LVL 24

Expert Comment

by:SunBow
Comment Utility
?
0
 

Author Comment

by:Mark Ebden
Comment Utility

Sorry for the delay, it took a while to get to the computer again.

Unfortunately it still doesn't work; removing the -i option did not change the error message:

 Login incorrect.
 Login failed

I repeat, are you able to successfully run such a script in Windows 2000 yourself?


thank you,

Mark
0
 

Accepted Solution

by:
ComTech earned 0 total points
Comment Utility
This question will be placed in PAQ and points refunded.

Best regards,
ComTech
Community Support
Administrator @ EE
0
 

Expert Comment

by:paulsaji
Comment Utility
I've seen this question on ftp while searching on  google.
In order to make this script work try it with  the -n option of ftp. I've tested this script on Windows 2000.
It works. Good luck.

Saji
0
 

Author Comment

by:Mark Ebden
Comment Utility

Thanks
0
 

Expert Comment

by:bjzielinski
Comment Utility
The problem I found is that the main.bat adds spaces at the end of each line in myscript.txt.  Remove those spaces using notepad or whatever and the script works fine.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
A short article about a problem I had getting the GPS LocationListener working.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

771 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

9 Experts available now in Live!

Get 1:1 Help Now