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

  • Home
  • SEARCH
  • 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 9235735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:07:22+00:00 2026-06-18T07:07:22+00:00

I have a C program that reads accelerometer data continously via i2c. Whenever the

  • 0

I have a C program that reads accelerometer data continously via i2c. Whenever the orientation of the tablet has changed, it outputs a new line to stdout.

Now, I want to be able to use that output in a bash script to change the rotation of the screen.

Now, the problem is this: When I view the output of the program in bash, the program is outputting the changes line by line. When I redirect the output to a file, output is written continously in the file, but when I try to pipe the output, nothing is happening.

Here is the C program:

#include <stdio.h>

int main(int argc, char *argv[])
{
    int changed;
    char *orientation;

    while (1) {
        /* Read data from i2c, check for change in orientation */
        if (changed) {
            fprintf(stdout, "%s\n", orientation);
            fflush(stdout);
            changed = 0;
        }
    }

    exit(0);
}

And here is my trial in bash:

#!/bin/bash

# This does not work, xrandr is not called.
./i2c-rotation | xargs xrandr --orientation 
# This is working
#./i2c-rotation > output
  • 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-18T07:07:23+00:00Added an answer on June 18, 2026 at 7:07 am

    By default, xargs wants to read a lot of arguments before running a command with them all. It’s probably not what you want in this case.

    xargs -L1 runs the command after each complete line of input.

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

Sidebar

Related Questions

I have a program that reads arbitrary data from a file system and outputs
good day sirs. i have a small program that reads and processes data via
I have a server program that reads data from a remote stream via TCP,
I have a program that reads data from a file line-by-line. I would like
I have a small program that reads in a file and processes the data
I have a simple program that reads data from a PNG into a 2D
I have this program that reads 2 Kb Data from a binary file adds
I have a program that reads financial data in JSON and inserts it into
I have a program that reads each line of file, extracting data according to
I have written a C++ program that reads in a file and outputs 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.