I have a headless Ubuntu server. I ran a command on the server (snapraid sync) over SSH from my Mac. The command said it would take about 6 hrs, so I left it over night.
When I came down this morning, the Terminal on the Mac said: «Write failed: broken pipe»
I’m not sure if the command executed fully. Is this a timeout issue? If so, how can I keep the SSH connection alive overnight?
asked Nov 5, 2012 at 8:31
![]()
Garry PettetGarry Pettet
8,05622 gold badges65 silver badges103 bronze badges
4
This should resolve the problem for Mac osX version: 10.8.2
add:
ServerAliveInterval 120
TCPKeepAlive no
to this file:
~/.ssh/config
Or, if you want it to be a global change in the SSH client, to this file
/private/etc/ssh_config
«ServerAliveInterval 120» basically says to «ping» the server with a NULL packet every 120s, and «TCPKeepAlive no» means to not set the SO_KEEPALIVE socket option (since you shouldn’t need it with ServerAliveInterval already set, and apparently it’s «spoofable» or some odd).
The servers similarly have something they could set for the same effect (ClientKeepAliveInterval) but typically you don’t have control over those settings as much.
answered Feb 19, 2013 at 16:22
3
You can use «screen» util for that. Just connect to the server over SSH, start screen session by «screen» command execution, start your command there and disconnect (don’t exit screen session). When you think your command already done you can connect to the server and attach to your screen session where you can see the command execution result/progress (in case one should be).
See «man screen» for more details.
answered Sep 25, 2013 at 18:25
![]()
humkinshumkins
9,54711 gold badges57 silver badges74 bronze badges
3
This should resolve the problem for ubuntu and linux mint
add:
ServerAliveInterval 120
TCPKeepAlive yes
to
/etc/ssh/ssh_config file
answered Mar 21, 2016 at 10:09
![]()
Instead of screen I’d recommend tmux, an (arguably) better competitor to screen
tmux new-session -s {name}
That command creates a session. Any time after that you want to connect:
tmux a -t {name}
answered Dec 27, 2014 at 14:41
jmvbxxjmvbxx
9763 gold badges13 silver badges21 bronze badges
there are two solutions
- To update server and restart server sshd
echo "ClientAliveInterval 60" | sudo tee -a /etc/ssh/sshd_config
- To update client
echo "ServerAliveInterval 60" >> ~/.ssh/config
answered Apr 28, 2015 at 16:39
XuanyuXuanyu
6015 silver badges11 bronze badges
After having tried to change many of above parameters in sshd_config (ClientAliveInterval, ClientMaxCount,TCPKeepAlive…) nothing had changed. I have spend hours and days to look for a solution on forums and blogs…
It appears that the problem of broken pipe which forbids to connect with ssh/sftp came from permissions settings on ChrootDirectory.
the ChrootDirectory has to be owned by root/root with 755 permision
lower permissions 765/766/775… won’t work but strongers do (eg 700)
if you need to give a write permission to connected user, you can give it in sub-directories.
if chroot is owned by sftpUser:sftpGroup, it won’t work neither…
chroot-> root:root 755
|
---subdirectories-> sftpUser:sftpGroup 700 up to 770
hope it would help
answered Dec 4, 2018 at 9:32
![]()
DavidDavid
4828 silver badges17 bronze badges
If you’re still having problem after editing /etc/ssh/sshd_config or if ~/.ssh/config
simply does not exist on your machine then I highly recommend reinstalling ssh. This solution took about a minute to fig both «Broken pipe» errors and «closed by remote host» errors.
sudo apt-get purge openssh-server
sudo apt update
sudo apt install openssh-server
answered Jan 15, 2019 at 6:38
2
jeremyforan’s answer is correct, however I’ve found that if you are trying to use scp it is necessary to explicitly point it to a config file configured as described, it seems to not obey the normal hierarchy of config. For example:
scp -F ~/.ssh/config myfile joe@myserver.com:~
works, while omitting the -F still results in the broken pipe error.
answered Jun 29, 2015 at 19:12
![]()
Ubuntu :
ssh -o ServerAliveInterval=5 -o ServerAliveCountMax=1 user@x.x.x.x
answered Feb 21, 2019 at 8:57
![]()
0
I use an ASUS router with two internet input lines. I appoint my IP to a certain line, and it works.
answered Apr 14, 2018 at 17:45
![]()
Description
Mikhail Efremov
2013-06-20 17:40:04 MSK
-bash: echo: ошибка записи: Обрыв канала Это из-за /etc/profile.d/infinality-settings.sh: if [ "$SET_XFT_SETTINGS" = "true" ]; then echo "$XFT_SETTINGS" | xrdb -merge >/dev/null 2>&1 fi потому как xrdb: Can't open display '' Можно проверять DISPLAY или просто if [ "$SET_XFT_SETTINGS" = "true" ]; then echo "$XFT_SETTINGS" | xrdb -merge fi >/dev/null 2>&1 Впрочем, возможно использование xrdb в /etc/profile.d/ - это вообще зря, не место ли этому всему где-нибудь в /etc/X11/xinit.d/?
Comment 1
Repository Robot
2013-06-24 21:33:07 MSK
libfreetype-infinality-2.4.12-alt2 -> sisyphus: * Mon Jun 24 2013 Dmitry V. Levin <ldv@altlinux> 2.4.12-alt2 - infinality-settings.sh: relocated from /etc/profile.d/ to /etc/X11/profile.d/ (closes: #29093). - Reintroduced ld.so.conf.d based configuration (closes: #29095).
I am running Ubuntu 14.04.3, it’s uptodate. I don’t know why, for a few days I began to take grep: write error: Broken pipe message on launching gnome-terminal . It seems to be harmless but it bothers me. How can I debug it?
EDIT: I moved aliases and functions each to separate files such as .bash_aliases and .bash_functions and added a command to load them from .bashrc
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
if [ -f ~/.bash_functions ]; then
. ~/.bash_functions
fi
If I don’t load .bash_functions problem disappears.
I am trying to find the faulty one by disabling each function one by one.
This one gives me the same error but when I disable it I keep getting the same error, so I may have more faulty functions.
ls -lt $PWD| grep ^d | head -1 | cut -b 51-
grep: development
write error: Broken pipe
I wonder why I begin to take that error.
EDIT2:
I found a similar problem here boken pipe
The root of the problem also seems similar.
I tried the given test command in the link which have the same error:
bash -c '(while echo foo; do :; done); echo status=$? >&2' | head
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
bash: line 0: echo: write error: Broken pipe
status=0
EDIT3:
Though that unbuffer workaround I posted below as an answer to my own question works, I am not satisfied with it, but my knowledge about debugging is limited. Acoording to this link https://lists.gnu.org/archive/html/bug-coreutils/2007-11/msg00080.html it stems from SIGPIPE trap by another task, and this link https://lists.gnu.org/archive/html/bug-coreutils/2007-11/msg00154.html pinpoints the exact cause of the problem, it’s one of the pam authentication module which I am in trouble with it recently.
- Печать
Страницы: [1] Вниз
Тема: mplayer, grep, awk, notify-send — как их подружить? (Прочитано 1055 раз)
0 Пользователей и 1 Гость просматривают эту тему.

Блуждающая девственница
Задача: Слушать интернет-радио через mplayer и выводить в notify-send имя исполнителя и название песни.
Как я слушаю и что пытался сделать:
mplayer -ao alsa http://radio.spark-media.ru:8000/nashe | grep "StreamTitle=" | awk --field-separator="=" '{print $2}' | notify-send -i dialog-informationНе работает. Почему-то или grep дальше не отдает или awk не берет, до notify-send вывод вообще не доходит.
Вопрос, как заставить сие играть и выводить в notify-send первым аргументом имя исполнителя, а вторым название песни?
Просто mplayer выводит:
ICY Info: StreamTitle='Пикник - Фиолетово-Чёрный';

Vovans
дело тут вовсе не в грепе или авк, а в notify-send как минимум. Вот попробуй ему скормить нужное:
echo "Пикник - Фиолетово-Чёрный" | notify-send
No summary specified.
bash: echo: ошибка записи: Обрыв канала
оно принимает только так: `notify-send «Пикник — Фиолетово-Чёрный»` 
—
о линукс по-русски: ссылка вырезана
—
ссылки — в профиль, в поле url
— kwah
« Последнее редактирование: 24 Августа 2009, 15:12:15 от Kwah »
- Печать
Страницы: [1] Вверх
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
How can we overcome Broken pipe error during scp,SFTP,Rsync while transferring big files.?
Hello All,
Hope all are doing well.
We use scp (some times sftp and rsync also) for transferring big files (around 2GB each ) from 1 Network to another Network.
The Issues which we face :-
During transfer some times( Once in 1 week (or twice)) , the speed of transfer gets down to 30 kb/s,… (2 Replies)
Discussion started by: Upendra Bhushan
2. Solaris
RWSocket::send: Broken pipe Error in /var/adm/messages
Hi Guys,
I am getting some strange error in /var/adm/messages in my Solaris 10 box with Veritas Cluster and EMC storage.
bash-3.00$ cat /var/adm/messages | egrep -v «lw8|snmp|sshd|xntpd|kern.info|LOGIN|link|service|started|finished|repeated|SS7 Log-daemon|success»
Dec 18 09:58:35 GAMMa2… (1 Reply)
Discussion started by: vivek.goel.piet
3. UNIX for Dummies Questions & Answers
SFTP error between UNIX to iSeries (Write Failed Broken Pipe)
Hi,
I am iseries resource and having Issue in one of the sFTP failures between one of my job (Unix —> iSeries).
The response to sending machine (Unix) is «Write Failed Broken Pipe».
Appreciate any help Available on why this Issue happens, how can we replicate the same, what fixes can… (1 Reply)
Discussion started by: hamelchauhan
4. Shell Programming and Scripting
How to avoid ssh :Write failed: Broken pipe?
Hello,
I am trying to run some code on Matlab over ssh . The code takes around 5-6 hours to complete. so after giving the command to run it , I locked my machine and then went off to sleep at night, only to discover in the morning that I get this message :
…Code running, partial results… (1 Reply)
Discussion started by: ajayram
5. UNIX for Dummies Questions & Answers
broken pipe error
I’m new to scripting, and this forum has been invaluable in helping me out. I’m hoping I can get some personal help now though.
I have a korn script that takes a list of servers and either telnets or sshs into it (only some are set up for ssh). What I’m doing now is trying to telnet first, and… (10 Replies)
Discussion started by: aimeet
6. UNIX for Advanced & Expert Users
write failed: Broken pipe
The «write failed: Broken pipe» message is reported by the file sending PC which run my writed network device driver while 500MB or 900MB is sended!
What does the message mean? Does this mean there is a bug in my driver?
li,kunlun (11 Replies)
Discussion started by: liklstar
7. Shell Programming and Scripting
Broken Pipe error
Hello
while doing sftp over server «A» , i am getting a broken pipe error i.e
cat: write error: Broken pipe
what does that mean? please let me know if you want any other info on this.. (3 Replies)
Discussion started by: urfrnddpk
8. UNIX for Advanced & Expert Users
sftp error:- Couldn’t send packet: Broken pipe
Hi,
I am trying to sftp a large file(appx. 2 GB size) from solaris 10 to a Linux server. While sftping(with no options), connection is terminated after some time with broken pipe error. sftp with option -R1 or -B1500 is successful.
Linux server ssh Version: OpenSSH_3.9p1, OpenSSL 0.9.7a… (3 Replies)
Discussion started by: brij123
9. Programming
Broken Pipe error
All,
I am using the below code
The C code :
if ((fp2=fopen(szout_fname,»r»))==NULL)
{
sprintf(stream_ptr1,»cat %s | sort -t, -rn -k 11,11 | awk -F»,» ‘{
if ( $3 ==»%s» ) {print… (0 Replies)
Discussion started by: arunkumar_mca
10. AIX
broken pipe error
Hi,
I am working on AIX 5.3 . I have client-server program which is in ProC.while sending packet to server i am getting error as broken pipe and program exiting.
please help?/? (1 Reply)
