Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Data from a UNIX Server

Status
Not open for further replies.

SkipVought

Programmer
Dec 4, 2001
47,489
US

I can perform an FTP for a specific file on a UNIX server.

But what if I only know a part of the path and I want to do something like...
Code:
    Dim oFSO, oFolder, oFile
    Dim hINetSession, hSession, sGetFile As String, sPutFile As String
    
    sGetFile = "//prod21/i2/prod/fp/models/mach/reports/"
    sGetFile = sGetFile & "build_plan/"
    
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    
    For Each oFolder In oFSO.GetFolder(sGetFile).SubFolders
        For Each oFile In oFolder.Files
            Debug.Print oFile.Path
        Next
    Next
Is there a method for returning the sub folders in a folder in UNIX, via VBA?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
:/

Maybe... dynamically create a script file, run ftp from the shell using a script file, pick up the results?

Should be able to run the script asynchronously and do a while loop on the task id to see if the ftp window is still up, and close the ftp window as part of the script?

Unfortunately I don't think ftp commands allow for any programming logic, so if you're trying to selectively download files... yeah I dunno.
 
Gruuuu,

Thanks for the reply. I have no problem with PUTTING data into a file. You can see that I have sGetFile & sPutFile strings, if I know that I'm getting and I can do THAT.

But I don't know what I'm looking for, and over time, the path structure may change to reflect our manufacturing environment.

SO are there methods other than FTP, for interrogating and accessing data in UNIX from a Windows environment?


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
putty does PSFTP and PSCP. It can also do scripts and logging, but I don't believe there's an API for it.

If you have access to the unix shell, which I am assuming you do, there's the option to store shell scripts and run them from putty to determine the directory structure. You can save that output into a log.

and putty can be run from the command link to run scripts.

Also found this: Looks like some sort of FTP VB methods? Maybe you can add a reference to [small]?[/small] ? [small]?[/small]whatever[small]?[/small] ? [small]?[/small] API it is that random guy on the internet is talking about?
 
command link. Heh.

Clearly I meant command line.

clearly.
 
interrogating and accessing data in UNIX from a Windows environment
I'd ask the unix sysadmin if SAMBA is an option.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
>Is there a method for returning the sub folders in a folder in UNIX, via VBA

Sure. And if you can unwed yourself from INet then it is all rather easy. Indeed, if you unwed yourself from the Inet stuff then all the file copying is pretty easy as well. For example:
Code:
[blue]   [green]' Requires a reference to Microsoft Shell Controls and Automation[/green]
    Dim ftpfolder As Shell32.Folder
    Dim ftpshell As Shell32.Shell
    Dim item As Shell32.FolderItem
    Dim fileitem As Shell32.FolderItem
      
    Dim sGetFile As String
    
    sGetFile = "ftp://"
    [green]' if we require a username and password:
    ' sgetFile = sGetFile & "myusername:mypassword@"[/green]
    sGetFile = sGetFile & "ftp.nai.com/commonupdater/"
    sGetFile = sGetFile & "current/"

    Set ftpshell = New Shell32.Shell
  
    Set ftpfolder = ftpshell.NameSpace(sGetFile)
    For Each item In ftpfolder.Items
        If item.IsFolder Then
            For Each fileitem In item.GetFolder.Items
                If Not fileitem.IsFolder Then Debug.Print fileitem.Path
            Next
        End If
    Next
   
    [green]'investigate the CopyHere method to see how easily you can copy to and from FTP servers[/green][/blue]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top