Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9000945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:22:23+00:00 2026-06-16T00:22:23+00:00

I have a setInterval who logs the time every second. I want to use

  • 0

I have a setInterval who logs the time every second.
I want to use STDIN to execute commands in my script, but the STDOUT is moving the cursor while I’m typing and puts itself in the prompt.

I don’t have much experience with prompts, just started diving into this.

Script:

setInterval(function(){
    console.log(new Date().toUTCString());
},1000)

var readline = require('readline');

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.question("Hi there, how are you?", function(answer) {

});

Output:

Hi there, how are you?Mon, 17 Dec 2012 16:20:34 GMT
fine
Mon, 17 Dec 2012 16:20:35 GMT
Mon, 17 Dec 2012 16:20:36 GMT
Mon, 17 Dec 2012 16:20:37 GMT
Mon, 17 Dec 2012 16:20:38 GMT

How would you solve something like this? Cache all the STDOUT, clear the screen, write all the STDOUT and prompt again every time console.log() is logging?

Yes I do want to create some kind of chat based system/command line interface where the output stays above the input.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:22:24+00:00Added an answer on June 16, 2026 at 12:22 am

    Basically what you are asking is how to make a complex terminal application. The most popular library for this is called ncurses and it has node bindings here. I don’t have personal experience using it unfortunately.

    Your other option would be to do as your said, and manually re-render the terminal using your own internal buffers. You can get the size of the output terminal using Node’s tty module, docs here, and then use ANSI escape codes to clear the terminal, position the cursor where you want, and then use process.stdout.write to print what you want.

    You can see an example of using escape codes in my other question over here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have one setinterval method which call php script every 3 sec to check
I have written a javascript function that uses setInterval to manipulate a string every
I have a function that use setInterval() method to watch css propertie change('cause in
have written this little class, which generates a UUID every time an object of
Basically, what I have is a setInterval inside a function. What I want to
I have a timer every 20 seconds using setInterval, it uses jQuery's ajax function
I have a setInterval running a piece of code 30 times a second. This
I have a Node.js process (setInterval) that runs every 100ms. I have certain actions
I'm learning about setTimeout vs setInterval and I have got setInterval to work but
I have a jQuery setInterval function named timerIncrement that times out (stops incrementing the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.