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 8443239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:05:12+00:00 2026-06-10T09:05:12+00:00

I wrote a little command line script to process a document [a markdown file

  • 0

I wrote a little command line script to process a document [a markdown file with lilypond musical notation inserts, just for completeness’ sake].

#!/usr/bin/env php
<?php    

$body = "";

...
// text gets processed here and stored in $body
...

ob_start();
include 'template.php';
file_put_contents(
    __DIR__ . '/' . str_replace('.md', '.html', $argv[1]),
    ob_get_flush() 
);

template.php

<!DOCTYPE html>
<html lang="en">
<head>
  ...
</head>
<body>
  <div id="wrapper">
  <?php echo Markdown($body); ?>
  </div>
</body>
</html>

When I call:

$ ./phlily source.md

File gets generated properly, but the template contents are printed to console too:

GNU LilyPond 2.14.2
Processing `/Users/.../phlily/ly/4add05a74d249f34b3875ef6c3c1d79763927960.ly'
Parsing...
Converting to PNG...
<!DOCTYPE html>
<html lang="en">
<head>
...
</html>

and it’s annoying because I want to read errors and warnings from the LilyPond script, being them buried behind the html wall in terminal.

Long story short, is it possible to shut the output buffer up in CLI environment?

  • 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-10T09:05:14+00:00Added an answer on June 10, 2026 at 9:05 am

    I think you want ob_get_clean() instead of ob_get_flush():

    ob_get_clean:

    ob_get_clean — Get current buffer contents and delete current output buffer

    ob_get_flush:

    ob_get_flush — Flush the output buffer, return it as a string and turn off output buffering

    In this case, “flush” means “send to stdout”.

    file_put_contents(
        __DIR__ . '/' . str_replace('.md', '.html', $argv[1]),
        ob_get_clean() 
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here I wrote a little app which is able to read command line arguments
I wrote a little search script for a client, it works and words get
I wrote a command line utility using Zend Framework to do some nightly reporting.
So I wrote a little script in python that brings up a gui with
I am trying to write a wrapper script for a command line program (svnadmin
I've written a little Ruby command line app that I use to keep TV
I've recently started learning Python and wrote a little script that informs me when
I just wrote a little program which will be executed as a post-build step
i'm creating a batch file and just a little thing i want to know:
I write a lot of little scripts that process files on a line-by-line basis.

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.