Problem solve Get help with specific problems with your technologies, process and projects.

Obtaining file names in the default directory of an FTP server via a script

I have an NT server with FTP server running on it. I have another with IIS 5 and ASP, etc. I would like to be able to obtain the file names of the files in the default directory on the FTP server via a script of some kind.

For example, in the Web application, I would like to ASSIGN a new file name for the Web user, by having a known list. The process does not have to be real time. I could have it check after the user completes the action, and the script continues. The user load is light.

File names are typically a1.txt a2.txt a3.txt etc. I need to assign the next one, a4.txt.

Some commands that work:

  • ftp ftp.server.com
  • username
  • pw
  • ls *.txt
  • quit

    This could capture all the filenames. Maybe this could be a .bat file on the Web server, called by the script. Then the script does some kind of file open, and read the filenames into an array, and sort them. Then parse the "latest" name. (The names are computer generated, so they follow some rules.) Then the script would continue to do whatever with that name known.

    Is this possible? Is there a better way? Such as using a Visual Basic executable and calling it from the .ASP? (I know that Microsoft restricts access to "drive" functions to the current drive that the Web root is on, so that's out.) How can this be done? How much work is it?

    I hope you know this off the top of your head. I wouldn't want you to burn time thinking or researching this, but if you know the answer, or have any ideas, I would appreciate your thoughts on this matter.

    I'm here to answer questions! Yes, what you are proposing is easily done. Instead of using a scripting approach I would lean towards either a Visual Basic 6 application or a .NET application. For VB6, there are many ActiveX controls that make accessing FTP servers trivial. Alternatively, Microsoft's new .NET framework has all of the functionality you need directly built into the environment. In fact, you can access FTP servers just like any directory. Using the .NET approach, doing this project would be a total of a day start to finish.
  • This was last published in April 2002

    Dig Deeper on Windows Server storage management

    Have a question for an expert?

    Please add a title for your question

    Get answers from a TechTarget expert on whatever's puzzling you.

    You will be able to add details on the next page.

    Start the conversation

    Send me notifications when other members comment.

    Please create a username to comment.