Link to home
Start Free TrialLog in
Avatar of aarons34
aarons34

asked on

Ftp Prompt Question

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
Avatar of dtkerns
dtkerns

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

SOLUTION
Avatar of dtkerns
dtkerns

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aarons34

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi aarons34,
> DOS shell called from a VB6 routine
There should be a better way to do this via some API call.

Cheers,
Stefan
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
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!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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