Uploaded command window contents to somewhere online?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
This isn't entirely a Matlab question, but I was wondering if someone knew of a website in which I could take the contents of the command window and upload it to a website so that it can be accessed from anywhere? I have a script that gathers data from a truck and finds how many files have been downloaded recently and also the trucks last location. I can use the diary function to save the command window contents to a text file, but I was wondering if there is a Matlab function that sends that info to a website? Also, that information would need to be update automatically. So if the script is run every day, the website would show the most recent information from that day.
0 comentarios
Respuesta aceptada
Cedric
el 30 de Jul. de 2013
Editada: Cedric
el 31 de Jul. de 2013
The two main options are, assuming that you have access to some scheduler (crontab, etc) on the machine that runs MATLAB..
1. You build a webpage with PHP script which uses some data file output-ed by your script to build the webpage content.
2. You generate the webpage directly with MATLAB.
In both cases though, the web server and MATLAB must run on the same machine, or you must use tools for performing automatic FTP (SFTP, WGET/PUT, etc) for transferring data files or web pages.
EDIT: to help you start, here is an example for generating an HTML page using MATLAB. If you don't know HTML, you can learn the basics here: http://www.w3schools.com/
Save the following function in your system:
function exportHTML(filename, nFiles1day, nFiles3day, nFiles7day, ...
lastLocation, latestFile, lastTruckMove)
fid = fopen(filename, 'w') ;
if fid < 0
error('Unable to open %s for writing.', filename) ;
end
fprintf(fid, '') ;
fprintf(fid, '<h1>Truck Tracking Tool by Jacqueline</h1>') ;
fprintf(fid, '*Exported on %s*<br/>', datestr(now)) ;
fprintf(fid, '<table border="1">') ;
fprintf(fid, '<tr><td># files last day</td><td>%d</td></tr>', nFiles1day) ;
fprintf(fid, '<tr><td># files last 3 days</td><td>%d</td></tr>', ...
nFiles3day) ;
fprintf(fid, '<tr><td># files last 7 days</td><td>%d</td></tr>', ...
nFiles7day) ;
fprintf(fid, '<tr><td>Last location</td><td>') ;
for k = 1 : length(lastLocation)
fprintf(fid, '%s<br/>', lastLocation{k}) ;
end
fprintf(fid, '</td></tr>') ;
fprintf(fid, '<tr><td>Latest file</td><td>%s</td></tr>', latestFile) ;
fprintf(fid, '<tr><td>Last truck move</td><td>%s</td></tr>', ...
lastTruckMove) ;
fprintf(fid, '</table>') ;
fprintf(fid, '') ;
end
Then run the following code, that emulates the output that you should get from your functions and calls the export function above:
nFiles1day = 3 ; % Return from updated verison of matdatesearch1().
nFiles3day = 16 ;
nFiles7day = 48 ;
lastLocation = {'720 Aero Drive, Buffalo, NY 14225, USA', ...
'Buffalo, NY 14225, USA', 'Cheektowaga, NY, USA', ...
'Erie, NY, USA', 'New York, USA', 'United States'} ;
latestFile = '20130729_SPLBRENT3_081610.mat' ;
lastTruckMove = '29-Jul-2013 10:13:32' ;
filename = 'index.html' ;
exportHTML(filename, nFiles1day, nFiles3day, nFiles7day, lastLocation, ...
latestFile, lastTruckMove) ;
You will see that it creates a file index.html on your disk, which you can open with a browser.
Hope it helps
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!