• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2588
  • Last Modified:

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
0
aarons34
Asked:
aarons34
  • 2
  • 2
  • 2
  • +3
3 Solutions
 
dtkernsCommented:
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
 
dtkernsCommented:
my version also has a -i option to turn it off

ftp -i host
0
 
aarons34Author Commented:
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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
TintinCommented:
-i turns off interactive mode.
0
 
stefan73Commented:
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
 
HamdyHassanCommented:
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
 
aarons34Author Commented:
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
 
HamdyHassanCommented:
-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
 
fridomCommented:
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

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now