Solved

Windows 2000: Need a quick ftp script please!

Posted on 2002-06-14
21
19,235 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
21 Comments
 

Author Comment

by:Mark Ebden
ID: 7079275

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
ID: 7129172
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
ID: 7129975

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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
LVL 1

Expert Comment

by:laax
ID: 7130843
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
ID: 7131338

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
ID: 7131486
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
ID: 7131931


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
ID: 7132239
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
ID: 7132308

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
ID: 7132321
The username and/or password is wrong.  Please check the values in the script file.
0
 

Author Comment

by:Mark Ebden
ID: 7132372

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
ID: 7132412
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
ID: 7132465

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
ID: 7133112
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
ID: 7133627

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
ID: 7158154
?
0
 

Author Comment

by:Mark Ebden
ID: 7164315

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
ID: 7268950
This question will be placed in PAQ and points refunded.

Best regards,
ComTech
Community Support
Administrator @ EE
0
 

Expert Comment

by:paulsaji
ID: 7397299
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
ID: 7399685

Thanks
0
 

Expert Comment

by:bjzielinski
ID: 10384386
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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Simple Linear Regression

695 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