Hudson : “yes: standard output: Broken pipe”

后端 未结 5 859
一生所求
一生所求 2021-02-18 19:02

I need to run a shell script in hudson. That script needs an answer from the user. To give an automatic answer I did the following command line :  

yes         


        
5条回答
  •  北海茫月
    2021-02-18 19:24

    The command yes being running in an infinite loop I supposed that this might be the solution :

    yes | head -1 | ./MyScript.sh #only one "Y" would be output of the command yes
    

    But, I got the same error.

    We can redirect the error to /dev/null as suggested by @J.F. Sebastian, or enforce that the command is correct by this :

    yes | head -1 | ./MyScript.sh || yes
    

    But, this suggestions were less appreciated. And so, I had to create my own named pipe, as follow :

    mkfifo /tmp/my_fifo #to create the named pipe
    exec 3<>/tmp/my_fifo #to make the named pipe in read and write mode by assigning it to a file descriptor
    echo "Y" >/tmp/my_fifo #to write into the named pipe, "Y" is the default value of yes
    ./MyScript.sh 

    I'm expecting more valuable solutions with greater explainations.

    Here it is an explaination for a file descriptor in linux.

    Thanks

提交回复
热议问题