473,320 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Dynamically updating a container from a text file

Hi all
I am using WScript.Shell in order to execute a batch file that runs a few commands with a large output that is redirected to a local text file.
When execution is finished, I read the text file and update a scrolling DIV on my html page with the output from the batch file.
Something like this:

Expand|Select|Wrap|Line Numbers
  1. Cmd="%comspec% /c script.bat > c:\output.txt"
  2. Exec=WshShell.Run(Cmd,0, true); 
  3. fso = new ActiveXObject("Scripting.FileSystemObject");
  4. ts = fso.OpenTextFile("C:\\output.txt", 1);
  5. msg = ts.ReadAll();
  6. var output = document.createElement('font');
  7. output.innerHTML=msg;
  8. div.appendChild(output);
  9.  
Thing is, this takes a long time and until the execution is finished, I cannot follow the log file to see what's going on.
My question is :
Is there anyway I can dynamically update my div with the content of the growing text file ?
Any suggestions will be great !

Thanks
Dec 29 '08 #1
12 2009
gits
5,390 Expert Mod 4TB
just to confirm - this is just a local running application?

kind regards
Dec 29 '08 #2
This is an intranet web page, on a local server running apache.
It is for internal use only.
No problem writing and reading from client file system.
Dec 29 '08 #3
gits
5,390 Expert Mod 4TB
but the wsh-script runs locally on every client? you might try an ajax-call to the local file ... may be some security restrictions might occur and have to be adjusted.
Dec 29 '08 #4
Can you please elaborate on the 'ajax-call to the local file' bit ?
I'm not sure I understand.
I thought ajax was a way to get info from the server.
What I need is to access a file on the client.

TIA
Dec 29 '08 #5
gits
5,390 Expert Mod 4TB
typically you are right ... but you do untypical things and so we might use untypical things too ;) ... the ajax-call is to be send to an url:

Expand|Select|Wrap|Line Numbers
  1. xmlHttp.open('GET', 'url', true);
where url could even be a local txt-file. there could be issues with cross-domain requests but those could be solved with security policies for the IE in your intranet i guess.

kind regards
Dec 29 '08 #6
Sorry for being difficult but I still don't realy understand.
Do you mean I can read a local text file using ajax ?
If so, please demonstrate how.

Thanks
Dec 29 '08 #7
gits
5,390 Expert Mod 4TB
ok ... here you go with FF ;)

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <script type="text/javascript">
  3.  
  4. function get_data() {
  5.     var xmlHttp = new XMLHttpRequest;
  6.  
  7.     xmlHttp.onreadystatechange = function() {
  8.         if (xmlHttp.readyState == 4) {
  9.             alert(xmlHttp.responseText);
  10.         }
  11.     }
  12.  
  13.     xmlHttp.open('GET', 'foo.txt', true);
  14.     xmlHttp.send(null);
  15. }
  16.  
  17. </script>
  18.  
  19. <body onload="get_data();">
  20. </body>
  21. </html>
  22.  
just put a file 'foo.txt' relative to this html file and write some text into it. the alert should show you the content of this file. i'll try it with IE too ...

kind regards
Dec 29 '08 #8
gits
5,390 Expert Mod 4TB
for IE this should work too ... but you need to instantiate the

ActiveXObject("Microsoft.XMLHTTP");

or

ActiveXObject("Msxml2.XMLHTTP")

accordingly.
Dec 29 '08 #9
This looks good, thanks!

So, will ajax calls allow me to read the file while the WshShell command is updating it ?
Dec 29 '08 #10
gits
5,390 Expert Mod 4TB
the webpage needs to start the ajax-call so you might use setInterval() to read the file from time to time ... you have to try it ... because i'm not quite sure whether there could be a file-access problem when the wsh uses or needs exclusive rights to write the file? i'm not quite familiar with those MS-things ;)

kind regards
Dec 29 '08 #11
Thanks. I will try ...

BTW - do you know of a better way to execute commands on a client other than the WshShell method ?

Of course, any method would have to be able to save the output somewhere.
Dec 29 '08 #12
gits
5,390 Expert Mod 4TB
well ... let us now whether it works or not ;) ... and unfortunatly i think i wouldn't have another idea besides the WSH on windows ... except that the entire task could be done in another way ... so something like transfering the data in question to the server and provide it from there instead of using a local file at the client ... as i said it seems quite strange to use client ressources from a webpage but in case you need it then it could be done of course :) ... we do some of such things with FF here for our applications ... so it is not strange enough to say - don't do it ... and i think for an internal app it is ok to do such things ...

kind regards
Dec 29 '08 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: willow1480 | last post by:
I am developing a small little Service Control Application. I am using a listview control with checkboxes and getting the list of services I want to control from a text file. When you check a...
8
by: simon | last post by:
On code behind file: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then Dim ctrl As New LinkButton ctrl.ID =...
4
by: sydney.luu | last post by:
Hello, I would greatly appreciate if someone can show me how to dynamically build a Repeater with unknown number of columns at design time. I have looked various threads in this newsgroup,...
3
by: keithb | last post by:
My code dynamically adds template fields to a GridView control. Everything seems to work OK, except when updating, because I haven't found a way to reference the dynamically added textboxes....
0
by: Silver Oak | last post by:
I have a DataGrid in which one of the columns is TemplateColumn that was created dynamically using iTemplate. I would like to have multi-row editing capability on the DataGrid. I'm trying to...
5
by: tshad | last post by:
I found I can create Template columns dynamically - as long as I don't use objects that need onclick events, such as a LinkButton. Textboxes and Labels work fine. I create the Template columns...
4
by: Craig Buchanan | last post by:
I dynamically add data-bound templates to a gridview in my ascx control. while this works correctly when the gridview is databound to the datatable, i'm having issues on postback. i would like...
7
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I'm adding subheadings to a gridview. Each sub head has a few link buttons. I'm adding the controls in the rowdatabound event code follows: sorry about the length here. I have to be missing...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.