Infinite loop issue when passing answers

I want to only pass the first answer to a function

echo "y" | install

and let the choice to the user to answer the next questions , but when i do that i get a infinite loop.


When using pipes, the shell changes so that the receiving programs standard input is the pipe and nothing else. You can't mix input from a pipe with un-piped input from the shell, it's simply not possible. When using pipes (or redirection) it's all or nothing.

Regarding the install program, what you think is an "infinite loop" is probably that it tries to read from standard input (which is the pipe), but as there is nothing more to read from the pipe it will simply wait for more input to arrive, which doesn't happen.

Joachim Pileborg's answer is entirely correct however for some usages you could use something like { echo y; cat } | install to send a leading y and then accept user input after that but that's only going to work for some circumstances/usages (it won't report character-by-character to the program for example).

If you really do need something like this then you can look into using the expect program as it was designed for this (among other things).

Category:linux Time:2019-01-10 Views:1

Related post

  • Wordpress multisite subdirectory redirect infinite loop issue 2014-03-25

    Any time I create a new site on my multisite install, I get an infinite loop redirect when navigating to that site's admin. I'm using the default htaccess supplied by WP for my subdirectory install. Here's what I have: RewriteEngine On RewriteBase /

  • WebForm.ReportViewer Infinite Loop Issue 2012-01-13

    I have a strange problem in Visual Studio 2010 (C#) using the Report Viewer to load an RDL file. I use the following code to load the RDL: //get the data set and then //. //. //pass the report to the viewer using (FileStream stream = new FileStream(_

  • - viewDidLoad infinite loop issue-(iOS) 2011-02-13

    I'm attempting to write a multiview app in iOS and really having a bit of a tough time... I've setup a new project and I've got a rootViewController being launched by the appDelegate. In turn, the rootViewController attempts to load and display my fi

  • Infinite loop error when trying to use mouseover function 2012-03-06

    This is driving me crazy for the last couple of days, and I can not figure it out. I am not that handy with JQuery. I am using Sponsor Wall plugin: What i am trying to do is to create a fu

  • How can I get around my "object reference" issue when passing messages to an actor? 2010-06-20

    A while back I put together a simple class named Actor that was my implementation of the Actor Model. Since then I've used it with great success (Minus some annoying workarounds for the lack of a discriminated union type.). I am left with an issue th

  • Infinite loop/recursion when implement quicksort in java 2011-04-15

    I'm attempting to implement quicksort in java in order to count the number of comparisons made, but I'm running into an infinite loop/recursive call situation, and I can't quite figure out where it's coming from. Through debugging I've determined tha

  • Facebook app infinite loop issue 2011-11-19

    My facebook app was working perfectly fine till this morning. The only change I made was that I changed the url to a local server. Later when I changed the url back to my deployment server, it gets stuck in an infinite loop with state and code variab

  • Infinite loop issue, comparing arrays in java 2012-01-05

    I'm trying to write a really small program in Java that takes a string as input and uses a function that generates a pseudo random chatacter and compares them to each element of the string, if they're the same the character gets written to a result a

  • how to handle infinite loop process when using proc_open 2012-03-19

    I use proc_open to execute a program created by c language. I was using file for the "stdout". $descriptorspec = array( 0 => array("pipe", "r"), 1 => array("file", "/tmp/example.output"), 2 => array("file", "/tmp/example.error", "a") ); Ever

  • Loop issues when counting lines in a .csv 2011-08-08

    It's me again still working on learning how it is possible for me to manage and manipulate .csv files using c++. I've made a small program that creates a new .csv file, fills in the table headings with generic labels, all named "value" for demonstrat

  • I am having continous loop issues when trying to boot after installing SP3 2014-11-07

    I have tried to boot in safe mode, and all other options but it will not boot at all and it won't boot from my disk either (says there is a corrupted file on my disk). Any ideas on how to get booted so that I can remove the SP3? ps - very disappointi

  • C002 issue when marking answers 2014-12-06

    1. Marking answers does not change the post to Answer. Several remarking attempts and two refreshes later, it finally appears as it should. 2. Deleting duplicate posts, mark answer on same thread then refresh causes all posts to reappear with no answ

  • Having IE Issues When Passing Object By Ref. and Dynamically Adding Properties 2011-09-20

    So, I've created a function to do some error checking on an XML file that I recieve from an AJAX call. Part of the validation is that the function then builds out an object for easy access while I process that data into a form. In FF, works like a ch

  • Curious DllImport issue, when passing a LONG parameter memory corruption 2011-10-24

    I've created a DLL function for using inside C# using DLLImport but having troubles in calling the method, as I'm getting memory corruption problems; [DllImport("mydll.dll", EntryPoint = "callinmydll")] public static extern int testdllcall(double *fi

  • codeigniter form validation issue when passing data from form to another one 2012-02-07

    I have a form in a page that pass the output data to another page containing another form. The problem is that when I try to browse the second page, the validation errors of this page are displayed, because it see the POST array from the form in the

  • intent issue when passing from one activity to the other 2012-02-25

    package nidhin.survey; import; import; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.*; import android.os.Bundle; import android.widget.CheckBox; imp

  • Memory management issues when passing items between arrays 2011-02-22

    I'm attempting to move a group of strings between three different places by calling this function getNextRandomItem. This works the first time I call it, but then I get an access error the second time. Can you explain what I'm doing wrong? New Items:

  • Infinite loop when using filter for jsp files 2010-09-04

    When I make filter for all jsp pages, the browser goes into an infinite loop, but when I make filter for only one page, it runs correctly!! Here is doFilter method, if some one find the error plx tell me... public void doFilter(ServletRequest request

  • Guess the number - Infinite loop when bad read 2011-05-21

    So I am making this Guess the number game in c++ that looks like this: #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { srand(time(0)); int secretNumber = rand() % 100 + 1; //Generate "Random

  • VBScript Data Validation - Numeric 1 Results in Infinite Loop 2011-02-24

    DISCLAIMER: I'm still an uber-n00b with programming concepts and know just enough VBS to hurt myself, so I'm likely to slur/slaughter some of the terms/concepts/ideas that are entailed with this program I'm trying to write. You, the vastly superior p

Copyright (C), All Rights Reserved.

processed in 0.672 (s). 13 q(s)