• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 134
  • Last Modified:

how to do commandline execution in html

   There are two textboxes to which 2 filenames are selected by means of "Browse..." buttons. I want to compare these 2 files using an existing software. How to run the software when I click the "compare files" button (In HTML)taking these 2 files as parameters.

   The file comparison software can be run in commandline as :     software_name file1 file2
please help
deepa
0
deepaot
Asked:
deepaot
  • 3
  • 3
  • 2
  • +3
1 Solution
 
dorwardCommented:
I'd submit the form to a server side process that saves the files, runs them through diff (pretty standard on UNIX and UNIX like systems), processes the output and then delete the temp files.
0
 
tripst3rCommented:
Expanding on what dorward said, you can't just call command line execution from a browser. Would you want a web page running a delete function on your hard drive?



0
 
ZvonkoSystems architectCommented:
Try this:


<html>
<head>
<script>
function doCompare(){
 oldFileName=document.forms[0].oldFile.value;
 newFileName=document.forms[0].newFile.value;
 if(oldFileName=="" || newFileName=="") return false;
 var tempFile = "F:\\temp\\compres.txt"
 var WshShell = new ActiveXObject("WScript.Shell");
 var oExec = WshShell.Exec("cmd /K fc "+oldFileName+" "+newFileName+" > "+tempFile+" & exit");
 while (oExec.Status == 0){
     //WScript.Sleep(100);
 }
 var ForReading = 1;
 fso = new ActiveXObject("Scripting.FileSystemObject");
 f = fso.OpenTextFile(tempFile, ForReading);
 alert(f.ReadAll())

 var fso = new ActiveXObject("Scripting.FileSystemObject");
}
</script>
</head>
<body>
<form>
<table>
<tr><td>
OldFile:</td><td>
<input type=file name=oldFile>
</td></tr>
<tr><td>
NewFile:</td><td>
<input type=file name=newFile>
</td></tr>
</table>
<input type=button value=Comapre
onClick="doCompare()">
<p>
</form>
</body>
</html>

Good luck,
Zvonko

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
substandCommented:
you can't do it in html.
0
 
ZvonkoSystems architectCommented:
Is my code no html?
0
 
substandCommented:
it includes javascript.  (at least it looks like javascript)

0
 
dorwardCommented:
JavaScript, Windows Scripting Host, and ActiveX.
0
 
ZvonkoSystems architectCommented:
Oh, two guys who can read!!! Or are you girls :-)

Hello deepa, did you try my proposal?

0
 
cocojohnCommented:
Zvonko's script can work only on IE with Scripting Host installed and script security set quite low.
It may be used in an intranet, but never on the web.

For all other browsers and configurations:
You can't compare files in the browser, you have to upload them and compare server-side.
0
 
COBOLdinosaurCommented:
This question has been classified abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.

<note>
Unless it is clear to me that the question has been answered I will recommend delete.  It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
</note>

If the user does not know how to close the question, the options are here:
http://www.experts-exchange.com/help/closing.jsp


Cd&

0
 
COBOLdinosaurCommented:
It is time to clean this abandoned question up.

I am putting it on a clean up list for CS.

<recommendation>
points to dorward

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&

0
 
substandCommented:
i think the question was answered in at least three different ways (dorward, zvonko, and substand) and all are correct, depending on the user's requirements (if they can do "no html" instead of wanting the answer "in html" as they said)

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now