JavaScript: tail a local file










0















After reading this question I noticed - despite the initial question - the solution provided works only for remote files unless you have a webserver.



Instead I'm looking for a solution (that doesn't use Node.js) to "tail -f" a local file (on the same machine where the script runs) in order to read its changes. The script runs in a QML item, so no browsers nor webservers are involved.



The file might be updated quite quickly: i.e. several times per second, but with few chars at time only.



I'm able to read the file's content using an XMLHttpRequest but it seems it doesn't fit for my purpose.



UPDATE



After the downvote and the closing request I try to explain in other words.



I'm working on a commercial device that offers a loader for QML objects only. I cannot write C++ applications, there's no compilers, etc...
Into /tmp folder there's a file that is continuously updated by a bash script. In my QML object I need to parse each line as soon as it is appended. The Qt version is 4.x and QtQuick is 1.1.



So I'm asking a way to achieve this goal with these constraints.










share|improve this question



















  • 1





    You said "a pure JavaScript way" but (a) XMLHttpRequest isn't "pure" JavaScript and (b) "pure" JavaScript has no input/output features at all, it depends entirely on the host environment to provide an API.

    – Quentin
    Nov 12 '18 at 8:13











  • It's written in the question: it's a QML object. Sorry for the misleading words, I will correct them. I mean without Node.js.

    – Mark
    Nov 12 '18 at 8:14











  • I know practically nothing of QML but a poke at the documentation says you should read the file from the main language for your app and then expose it to JS via a property binding and/or signal handler.

    – Quentin
    Nov 12 '18 at 8:18











  • @Quentin yes, that's the standard way and I'm doing it daily. This time I cannot use a backend C++ application. Hence I asked how to do this in JS only.

    – Mark
    Nov 12 '18 at 8:26






  • 1





    ECMAScript is the underlying language for JavaScript (typically written as "javascript" to mean implementations that support a DOM and i/o). Both require a host environment. ECMAScript has zero i/o, javascript has i/o depending on the implementation (e.g. various browsers, node, etc. see List of ECMAScript implementations).

    – RobG
    Nov 12 '18 at 8:36
















0















After reading this question I noticed - despite the initial question - the solution provided works only for remote files unless you have a webserver.



Instead I'm looking for a solution (that doesn't use Node.js) to "tail -f" a local file (on the same machine where the script runs) in order to read its changes. The script runs in a QML item, so no browsers nor webservers are involved.



The file might be updated quite quickly: i.e. several times per second, but with few chars at time only.



I'm able to read the file's content using an XMLHttpRequest but it seems it doesn't fit for my purpose.



UPDATE



After the downvote and the closing request I try to explain in other words.



I'm working on a commercial device that offers a loader for QML objects only. I cannot write C++ applications, there's no compilers, etc...
Into /tmp folder there's a file that is continuously updated by a bash script. In my QML object I need to parse each line as soon as it is appended. The Qt version is 4.x and QtQuick is 1.1.



So I'm asking a way to achieve this goal with these constraints.










share|improve this question



















  • 1





    You said "a pure JavaScript way" but (a) XMLHttpRequest isn't "pure" JavaScript and (b) "pure" JavaScript has no input/output features at all, it depends entirely on the host environment to provide an API.

    – Quentin
    Nov 12 '18 at 8:13











  • It's written in the question: it's a QML object. Sorry for the misleading words, I will correct them. I mean without Node.js.

    – Mark
    Nov 12 '18 at 8:14











  • I know practically nothing of QML but a poke at the documentation says you should read the file from the main language for your app and then expose it to JS via a property binding and/or signal handler.

    – Quentin
    Nov 12 '18 at 8:18











  • @Quentin yes, that's the standard way and I'm doing it daily. This time I cannot use a backend C++ application. Hence I asked how to do this in JS only.

    – Mark
    Nov 12 '18 at 8:26






  • 1





    ECMAScript is the underlying language for JavaScript (typically written as "javascript" to mean implementations that support a DOM and i/o). Both require a host environment. ECMAScript has zero i/o, javascript has i/o depending on the implementation (e.g. various browsers, node, etc. see List of ECMAScript implementations).

    – RobG
    Nov 12 '18 at 8:36














0












0








0








After reading this question I noticed - despite the initial question - the solution provided works only for remote files unless you have a webserver.



Instead I'm looking for a solution (that doesn't use Node.js) to "tail -f" a local file (on the same machine where the script runs) in order to read its changes. The script runs in a QML item, so no browsers nor webservers are involved.



The file might be updated quite quickly: i.e. several times per second, but with few chars at time only.



I'm able to read the file's content using an XMLHttpRequest but it seems it doesn't fit for my purpose.



UPDATE



After the downvote and the closing request I try to explain in other words.



I'm working on a commercial device that offers a loader for QML objects only. I cannot write C++ applications, there's no compilers, etc...
Into /tmp folder there's a file that is continuously updated by a bash script. In my QML object I need to parse each line as soon as it is appended. The Qt version is 4.x and QtQuick is 1.1.



So I'm asking a way to achieve this goal with these constraints.










share|improve this question
















After reading this question I noticed - despite the initial question - the solution provided works only for remote files unless you have a webserver.



Instead I'm looking for a solution (that doesn't use Node.js) to "tail -f" a local file (on the same machine where the script runs) in order to read its changes. The script runs in a QML item, so no browsers nor webservers are involved.



The file might be updated quite quickly: i.e. several times per second, but with few chars at time only.



I'm able to read the file's content using an XMLHttpRequest but it seems it doesn't fit for my purpose.



UPDATE



After the downvote and the closing request I try to explain in other words.



I'm working on a commercial device that offers a loader for QML objects only. I cannot write C++ applications, there's no compilers, etc...
Into /tmp folder there's a file that is continuously updated by a bash script. In my QML object I need to parse each line as soon as it is appended. The Qt version is 4.x and QtQuick is 1.1.



So I'm asking a way to achieve this goal with these constraints.







javascript file qml tail






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 9:26







Mark

















asked Nov 12 '18 at 8:11









MarkMark

1,07311433




1,07311433







  • 1





    You said "a pure JavaScript way" but (a) XMLHttpRequest isn't "pure" JavaScript and (b) "pure" JavaScript has no input/output features at all, it depends entirely on the host environment to provide an API.

    – Quentin
    Nov 12 '18 at 8:13











  • It's written in the question: it's a QML object. Sorry for the misleading words, I will correct them. I mean without Node.js.

    – Mark
    Nov 12 '18 at 8:14











  • I know practically nothing of QML but a poke at the documentation says you should read the file from the main language for your app and then expose it to JS via a property binding and/or signal handler.

    – Quentin
    Nov 12 '18 at 8:18











  • @Quentin yes, that's the standard way and I'm doing it daily. This time I cannot use a backend C++ application. Hence I asked how to do this in JS only.

    – Mark
    Nov 12 '18 at 8:26






  • 1





    ECMAScript is the underlying language for JavaScript (typically written as "javascript" to mean implementations that support a DOM and i/o). Both require a host environment. ECMAScript has zero i/o, javascript has i/o depending on the implementation (e.g. various browsers, node, etc. see List of ECMAScript implementations).

    – RobG
    Nov 12 '18 at 8:36













  • 1





    You said "a pure JavaScript way" but (a) XMLHttpRequest isn't "pure" JavaScript and (b) "pure" JavaScript has no input/output features at all, it depends entirely on the host environment to provide an API.

    – Quentin
    Nov 12 '18 at 8:13











  • It's written in the question: it's a QML object. Sorry for the misleading words, I will correct them. I mean without Node.js.

    – Mark
    Nov 12 '18 at 8:14











  • I know practically nothing of QML but a poke at the documentation says you should read the file from the main language for your app and then expose it to JS via a property binding and/or signal handler.

    – Quentin
    Nov 12 '18 at 8:18











  • @Quentin yes, that's the standard way and I'm doing it daily. This time I cannot use a backend C++ application. Hence I asked how to do this in JS only.

    – Mark
    Nov 12 '18 at 8:26






  • 1





    ECMAScript is the underlying language for JavaScript (typically written as "javascript" to mean implementations that support a DOM and i/o). Both require a host environment. ECMAScript has zero i/o, javascript has i/o depending on the implementation (e.g. various browsers, node, etc. see List of ECMAScript implementations).

    – RobG
    Nov 12 '18 at 8:36








1




1





You said "a pure JavaScript way" but (a) XMLHttpRequest isn't "pure" JavaScript and (b) "pure" JavaScript has no input/output features at all, it depends entirely on the host environment to provide an API.

– Quentin
Nov 12 '18 at 8:13





You said "a pure JavaScript way" but (a) XMLHttpRequest isn't "pure" JavaScript and (b) "pure" JavaScript has no input/output features at all, it depends entirely on the host environment to provide an API.

– Quentin
Nov 12 '18 at 8:13













It's written in the question: it's a QML object. Sorry for the misleading words, I will correct them. I mean without Node.js.

– Mark
Nov 12 '18 at 8:14





It's written in the question: it's a QML object. Sorry for the misleading words, I will correct them. I mean without Node.js.

– Mark
Nov 12 '18 at 8:14













I know practically nothing of QML but a poke at the documentation says you should read the file from the main language for your app and then expose it to JS via a property binding and/or signal handler.

– Quentin
Nov 12 '18 at 8:18





I know practically nothing of QML but a poke at the documentation says you should read the file from the main language for your app and then expose it to JS via a property binding and/or signal handler.

– Quentin
Nov 12 '18 at 8:18













@Quentin yes, that's the standard way and I'm doing it daily. This time I cannot use a backend C++ application. Hence I asked how to do this in JS only.

– Mark
Nov 12 '18 at 8:26





@Quentin yes, that's the standard way and I'm doing it daily. This time I cannot use a backend C++ application. Hence I asked how to do this in JS only.

– Mark
Nov 12 '18 at 8:26




1




1





ECMAScript is the underlying language for JavaScript (typically written as "javascript" to mean implementations that support a DOM and i/o). Both require a host environment. ECMAScript has zero i/o, javascript has i/o depending on the implementation (e.g. various browsers, node, etc. see List of ECMAScript implementations).

– RobG
Nov 12 '18 at 8:36






ECMAScript is the underlying language for JavaScript (typically written as "javascript" to mean implementations that support a DOM and i/o). Both require a host environment. ECMAScript has zero i/o, javascript has i/o depending on the implementation (e.g. various browsers, node, etc. see List of ECMAScript implementations).

– RobG
Nov 12 '18 at 8:36













0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53258075%2fjavascript-tail-a-local-file%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53258075%2fjavascript-tail-a-local-file%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo