Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Nov 2013
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How to make a text file get read on server?

    I apologize if this is the wrong section to post in, as I am not sure what process to take to make this work.

    I have my website which has a bunch of forms to fill out, mainly numbers. When the user is done filling everything, it saves the numbers into a text file.

    What I want, is for the server to get this text file and plug the numbers into a custom-made executable we have developed, run itself, and then return the results to the user.

    For various reasons, we can't just have the math sit in the code, it has to run on our server.

    What would be the best way to do this? I am honestly not sure where to even begin. Thanks for your help!

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,380
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    You'll have to post a few lines of the text file so we can see how it is structured. Specifically, if it's by lines, and data separated by delimiter? Show us some of it.

  • #3
    New Coder
    Join Date
    Sep 2013
    Posts
    17
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Try this function, it might help you: php dot net/manual/en/function dot readfile dot php

  • #4
    New Coder
    Join Date
    Nov 2013
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I apologize for the greatly delayed reply.

    This is an exact copy and paste of the text file created by the HTML/PHP:
    1
    1000000
    2425
    102e-05
    000035
    5e-05
    000135
    15
    120
    1e-15
    10000
    190
    80000
    100
    But I am sure I can change the output if that makes it easier...?

  • #5
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,380
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    What is the custom-made executable you have?
    is that a PHP script?

    I see there are some very small numbers ...
    1e-15 = .000000000000001

    Is that correct?

  • #6
    New Coder
    Join Date
    Nov 2013
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    The custom-made executable does all the number crunching, it virtually creates chemical reactions. (I hope that's what you were asking?)

    The text file was indeed created with a php file!

    And yes, there are some very small numbers being used, in that particular text file I put in the variables to see what happens if you mix chemicals in a vial.

  • #7
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,380
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    Is that custom-made executable a PHP script?

    I'm thinking that your question is more about how the custom-made executable gets the data from the website data file. We almost need to know what the executable is... C++ program? Perl, ASP?

  • #8
    New Coder
    Join Date
    Nov 2013
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Sorry for misunderstanding the question, the custom executable was created in Matlab and compiled as an executable.

  • #9
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,380
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    First of all, I'm not a MATLAB expert, nor do I have any experience with it.

    From what I've seen (via Googling), is that if you have your own server with PHP and MATLAB (together on the same PC/server), there are many connections to be made that allow them to work together.

    If an external website on a shared webhost is used ... like I think is happening with you,

    You have a website with a PHP script that people use to enter form data. Your PHP script writes data to a file (a URL on your website). Now, MATLAB uses the URLREAD command to GET the data from any URL (website file). Within MATLAB you parse that data.

    http://stackoverflow.com/questions/3...tlab-using-url

    So the answer to your question is really about MATLAB, and the URLREAD command.
    http://www.mathworks.com/help/matlab/ref/urlread.html

    You should create a plain text file with some numbers and upload that file to your website. That will just be a test file to see if you can get MATLAB to read the values. I'm guessing they will be in a line, separated by commas, like this:

    1,1000000,2425,102e-05,000035,5e-05,000135
    15,120,1e-15,10000,190,80000,100

    If you can get MATLAB to read your values from a test file, then you'll know what PHP needs to do in order to save the form values in the correct format. Basically, you're reverse engineering it. Make MATLAB work properly before you do the PHP form processing.

    If you discover anything in MATLAB that talks about having MATLAB read-in XML file from a website, let me know that too. PHP can create an XML file containing the data entered from your form. It would be another format, in lieu of using a .txt file with comma-separated variables.

    Does that make sense? I'm just not that familiar with MATLAB.


    EDIT:
    Also know that your website form, where people enter data, can use PHP to store that data in various files, depending on date, time, or any means of identification. Your MATLAB program could decide which files to read from your website based on those identifying features. Again, this all falls into the MATLAB capabilities to read any file from any website. For example, each vial mixed could have its own ID number. That ID number is part of the filename: vial_238.txt
    If MATLAB needed the values from vial number 238, it would know the filename is vial_238.txt, or other vial ID numbers ... vial_146.txt, etc. depending on the vial ID number.


    .
    Last edited by mlseim; 12-11-2013 at 02:13 PM.

  • Users who have thanked mlseim for this post:

    losttoys (12-14-2013)

  • #10
    New Coder
    Join Date
    Nov 2013
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you for the help! I have followed up on the links you provided and your explanation made sense. I think we can finally move forward, wish I was more of an expert like you guys here!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •