Solved

Ftp Prompt Question

Posted on 2004-04-20
9
2,558 Views
Last Modified: 2013-12-26
Hi,

I am using mget to download all the files within a directory from an ftp server to my local machine.

I am using something like this:

cd <remote directory>
lcd <local directory>
prompt
mget *

however, how can I make sure that interactive mode is OFF?  I know that by using prompt, the mode will toggle between On and OFF.

A couple of times I ran into the problem that interactive mode was already off and I turned it on with my program.

Is there a way to check this?

Thanks
0
Comment
Question by:aarons34
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 3

Expert Comment

by:dtkerns
Comment Utility
it's some what dependant on your version of ftp ... mine tells me:

ftp> prompt
Interactive mode off.
ftp> prompt
Interactive mode on.
ftp>

if you're scripting this (say via expect) you can make it smart enough to issue prompt until it's in the 'right' state

0
 
LVL 3

Assisted Solution

by:dtkerns
dtkerns earned 50 total points
Comment Utility
my version also has a -i option to turn it off

ftp -i host
0
 
LVL 1

Author Comment

by:aarons34
Comment Utility
Well, I'm making a DOS shell called from a VB6 routine in Access.

The problem that I have is since the ftp has to be hidden to the Access user, if I by mistake turn interactive mode on and do the mget, then the program will freeze waiting for an answer which will never get there because it's hidden.

Eventually I'll move this routine to a Visual Studio one but in the mean time it's imperative that it's always off.

What exactly does the '-i' part of the command do?

Thanks
0
 
LVL 48

Accepted Solution

by:
Tintin earned 50 total points
Comment Utility
-i turns off interactive mode.
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 12

Expert Comment

by:stefan73
Comment Utility
Hi aarons34,
> DOS shell called from a VB6 routine
There should be a better way to do this via some API call.

Cheers,
Stefan
0
 
LVL 9

Expert Comment

by:HamdyHassan
Comment Utility
Can you post source of " DOS shell" ?
and we try to make it work.

otherwise, you can use VBScript .vbs to do FTP and forget about .bat
0
 
LVL 1

Author Comment

by:aarons34
Comment Utility
stefan73:

I agree there should be a better way, and I would love to have it. I actually have another question open for that. However, the program is already working fine and I just need to make that validation. Therefore, It will take me less time to just adapt that part than to write a whole new module on VB6. I want to move in that direction, and if someone can provide me on how to do it awesome! especially because I hate having the password in a file that can be easily read with Notepad!

HamdyHassan:

Next is the code I am currently using in VB to create the .bat files:

For download, I use three:

'--------This one will delete all the used file when the program is over----------------
    Open "c:\delefiles.bat" For Output As #1
        Print #1, "del c:\download"
        Print #1, "del c:\dwnld.bat"
        Print #1, "del c:\delefiles.bat"
    Close #1

'------------- This is the one containing the tasks that I want to perform-------------
    Open "c:\download" For Output As #1
        Print #1, "myusername"
        Print #1, "mypassword"
        Print #1, "prompt"
        Print #1, "cd directory1"
        Print #1, "lcd c:\localdirectory1"
        Print #1, "mget *"
        Print #1, "cd .."
        Print #1, "cd directory2"
        Print #1, "lcd c:\localdirectory2"
        Print #1, "mget *"
        Print #1, "cd .."
        Print #1, "cd directory3"
        Print #1, "lcd c:\localdirectory3"
        Print #1, "mget *"                                 '------- I repeat through 15 directories
        Print #1, "Disconnect"                  
        Print #1, "bye"
    Close #1

'------------This is the DOS program that will call the ftp-----------------------
    Open "c:\dwnld.bat" For Output As #1
        Print #1, "ftp -i -s:c:\download 1.2.3.4"          '--------I included dtkerns suggestion now but I still don;t have a way to
                                                                          '--------know if it was already OFF to avoid the program to turn it ON
        Print #1, "EXIT"
    Close #1

'-------------After I created those files, I use:
Call Shell("c:\dwnld.bat", vbHide)
Call Shell("c:\delefiles.bat", vbHide)

The files are not big (between 1k and 3k) so it doesn't take long. I just want to make sure that the prompt is always OFF

Something like:

If 'prompt' = ON THEN
       turn prompt OFF
Else
       'leave it OFF
End if

I am going to make two things with this question:

1. I want to ask the moderator for advise because I think the experts are right and it's better to do it in vb. That way I don't have to call the shells and I can hide the password in an .exe or the vb code as part of the solution. will this be considered a new question?

Therefore, I would like to know if I have to post it as a different question or I can split the points at the end in this one?

2. I am willing to raise the points to 500 if I can get that code to be within the VB code of my solution and forgetting about the .bat files. If that is not posible but I get the same effect on my current DOS shells I'll go with 200.

Thanks!
0
 
LVL 9

Assisted Solution

by:HamdyHassan
HamdyHassan earned 100 total points
Comment Utility
-i
Disables interactive prompting during multiple file transfers.

Please go ahead with "-i" , It's not on-off issue as you think

If it's off , it will be off
If if's on, it will be off
It's "DISABLE" interactive prompting

Print #1, "ftp -i -s:c:\download 1.2.3.4"
0
 
LVL 24

Expert Comment

by:fridom
Comment Utility
You do not have to use vb for that just use the right tool for the job. For you either curl http://curl.haxx.se or wget may be the right choice.

That are command line tools with which you can automate download tasks.
e.g for getting all files in a directory you can use wget this way:

wget "ftp://server_I_want_to_get_my_stuff_from/path/*"

Adding passwords to is is a matter of providing some options.


Regards
Friedrich

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video discusses moving either the default database or any database to a new volume.

763 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

11 Experts available now in Live!

Get 1:1 Help Now