Subscribe Bookmark RSS Feed

Files in directory on http server

j_bonnouvrier

Community Trekker

Joined:

Dec 19, 2012

Hi,

 

I would like to know the list of files located on a http server, such as:

path = "http://extranet.MyCompany/suppliers/SupplierName/Supplier data/"

 

Using the JSL function:

Files In Directory (path)

Does not work, whereas, I can open each file using the function:

Open( http://extranet.MyCompany/suppliers/SupplierName/Supplier data/data.xls);

 

Would someone have any solution to my problem?

 

Thanks in advance and happy new year by the way!

 

Jérôme

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales

Staff

Joined:

Mar 21, 2013

Solution

What do you get when you open the SupplierData/ level?  There are at least two common answers: it might direct you to a less helpful webpage, or it might show you something like

 

Apache server directory listingApache server directory listing

That second case is something you might be able to use; InternetOpen gives me this:

JMP data table opened with internet open on an Apache server directory, showing file namesJMP data table opened with internet open on an Apache server directory, showing file names

If the directory is there, but not in an HTML table, internet open won't do what you need. But if you want to write some JSL to parse the directory names out of the HTML, you could. Something like this:

 

html = Open( "http://example.com/files" );

While(
    Pat Match(
        html,
        "<a href=\!"" + Pat Break( "\!"" ) >> filename + "\!">",
        ""
    ),
    If( Ends With( filename, ".JPG" ),
        Print( filename )
    )
);


"DSCF1539.JPG"
"DSCF1551.JPG"
"DSCF1563.JPG"
"DSCF1624.JPG"

This example depends on knowing a little bit about the structure of the HTML; you can use write(html) to see it in the JMP log or use your browser's right-click->viewPageSource function.

Apache is a common web server and can be configured (by default, I think) to show the directory listing. If there is an index.html page in the directory, I think that's what you'll get though...not so helpful sometimes.

There are also web services (webdav, others?) that might be applicable, but I don't know much about them. 

 

 

Craige
2 REPLIES
Craige_Hales

Staff

Joined:

Mar 21, 2013

Solution

What do you get when you open the SupplierData/ level?  There are at least two common answers: it might direct you to a less helpful webpage, or it might show you something like

 

Apache server directory listingApache server directory listing

That second case is something you might be able to use; InternetOpen gives me this:

JMP data table opened with internet open on an Apache server directory, showing file namesJMP data table opened with internet open on an Apache server directory, showing file names

If the directory is there, but not in an HTML table, internet open won't do what you need. But if you want to write some JSL to parse the directory names out of the HTML, you could. Something like this:

 

html = Open( "http://example.com/files" );

While(
    Pat Match(
        html,
        "<a href=\!"" + Pat Break( "\!"" ) >> filename + "\!">",
        ""
    ),
    If( Ends With( filename, ".JPG" ),
        Print( filename )
    )
);


"DSCF1539.JPG"
"DSCF1551.JPG"
"DSCF1563.JPG"
"DSCF1624.JPG"

This example depends on knowing a little bit about the structure of the HTML; you can use write(html) to see it in the JMP log or use your browser's right-click->viewPageSource function.

Apache is a common web server and can be configured (by default, I think) to show the directory listing. If there is an index.html page in the directory, I think that's what you'll get though...not so helpful sometimes.

There are also web services (webdav, others?) that might be applicable, but I don't know much about them. 

 

 

Craige
j_bonnouvrier

Community Trekker

Joined:

Dec 19, 2012

Thank you Craige for your answer.